Asp.Net MVC: My Personal View Rules
July 5th, 2010
I've been working with a team of guys on several Asp.Net MVC projects since October of 2009. While that isn't the greatest amount of time, and I'm still no expert, I thought I'd jot down a few of the practices that we have developed to help make coding a bit smoother. Asp.Net MVC, as with every new technology can be used poorly, and when use poorly you try to identify why that code was bad, how it could have been done better.
First, lets think about what the view should be doing - in a single responsibility sort of way: turn data into html. That right there rules out several options. No retrieving data, no extra data transformations. Just turn some data into html. And frankly, that is complicated enough. So a side goal that I strive for is to create a markup page (the aspx) that is similar to the desired html output. The main reason for that side goal is to make double checking the output that much easier. I want to see a 'div' in my markup, and have a reasonable idea where that 'div' will show up in the html.
- Keep as much code out of your views as you can.


