What’s different about Microsoft’s ASP.NET MVC (Model-View-Controller)?
There are some very good books about MVC (such as Steven Sanderson’s book), but here are the features I enjoy the most:
Routing – The routing model in MVC makes you really think about what you want your URLs to look like. In EVERY instance my application ended up much simpler than I originally thought.
Controller – The controller does most of the binding work for you so you don’t have to constantly set the values of controls in your code behind.
*-Driven Development – My top two would be Test Driven Development (TDD) and Model Driven Development. MVC reinforces both.
Extension Methods – The HtmlHelper class is quite powerful and one can easily extend it if features are missing. This lets you type something like:
- <{f073afa9b3cad59b43edffc8236236232bb532d50165f68f2787a3c583ed137f}= Html.DropDownListFor(model => model.Category, ViewData["Categories"] as SelectList) {f073afa9b3cad59b43edffc8236236232bb532d50165f68f2787a3c583ed137f}>
I feel fortunate that I worked with web applications for many years. That made the move to WPF (Windows Presentation Foundation) much easier than someone moving from WinForms. However, the Binding model was a significant change from WebForms. The notion that I didn’t have to constantly write MyTextBox.Text = model.Property in my code behind was a relief. I finally appreciated Binding and then started to work with MVC where the Controller class provides the same capability.
I still do very little client side code because it is typically so hard to test, but I see slow improvements.
Not for Every Problem
While MVC is very powerful, it does not need to be the only tool you use on the web. However, I find that for data driven applications the model is much more natural. Having just finished a full application and benefiting from the power of MVC it will be one of the most used tools for me. But have no fear… You can fairly easily mix and match traditional controls within MVC… I’ll eventually have some examples of that.
Leave a Reply