12

I am relatively new to ASP.NET MVC, and am very impressed with the clarity of the platform so far. However, there is one aspect that I find uncomfortable.

At first, I accepted the fact that when I say

return View();

I am calling a helper method that returns an ActionResult, and makes some assumptions about which view to present, route values, etc. But lately I have been writing code that looks more like this:

return View("Index", new { id = myID })

because it is immediately clear to me what's happening by reading that single line of code.

Lately I have been struggling with the fact that I can have an Index.ASPX view open on the tabs, and I can't immediately tell where it comes from because the IDE doesn't highlight the current tab in the Object Explorer. I haven't resorted to changing the names of the files to ControllerNameIndex.ASPX, but I do put a title in the view that is more specific. Still, it doesn't help much.

How do you deal with these kinds of ambiguities?

Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
  • 1
    I've been wondering the same thing - I look forward to reading responses from those more experienced. – Beep beep Jul 02 '09 at 04:34
  • 1
    I've just been relying on knowing which aspect of the site i've been working on and keeping track. Now and again i close all tabs in VS and start again. Now that i think of it that seems a little counter-productive. – griegs Jul 02 '09 at 04:44
  • 1
    That's what I've been doing. Great minds think alike, I guess. :) – Robert Harvey Jul 02 '09 at 04:48
  • 3
    Do whatever 'fits your mind' best. Having said that, your need for explicit-ness inclines me to believe you're a java/asp.net guy. You have to remember the convention>config argument stems from the ruby camp, where the language and community as a whole leans more that way. So to a c# mindset, you're probably finding it all a bit strange. – Chris Jul 02 '09 at 05:44
  • Chris, you should've posted that as an answer. – Jon Limjap Jul 02 '09 at 06:11

1 Answers1

6

I think you answered your own question.

There's no hard rule preventing you from calling your views very specific names, such as "ListOfFooBars" or "EditFizzBuzz" or "AddNewGeeblup". The naming convention for the default view engine only specifies that there's a folder corresponding to your model name under views, and there's an ASPX or ASPC file under that folder that corresponds to your view name.

Jon Limjap
  • 94,284
  • 15
  • 101
  • 152