1. Computing & Technology

Discuss in my forum

Dan Mabbutt

Sorting Through the New Toys - MVC

By , About.com GuideApril 28, 2010

Follow me on:

nullSay you have just installed your new Visual Studio 2010 and you're looking through the "New Project" dialog. Hmmm ... What's this? "ASP.NET MVC 2" Gee! I never knew there was an MVC 1.

If your day (and more) is fully consumed trying to hit the production deadlines of a job, you might be forgiven for failing to notice that Microsoft has been pumping a whole new, new way of programming ASP.NET, like, for-ever. The second "new" is because they switched to a completely new way once already with ASP.NET Version 2 using code-behind and partial classes. And "forever" is ... ummmm ... since last April, in practical terms. Microsoft's Scott Guthrie first said the word "MVC" in public in October 2007. Things move fast in software.

You could use MVC 1.0 with VB.NET 2008 and Framework 3.5 for most of last year, but you had to download it. Visual Studio 2010 made MVC a first class technology at Microsoft for the first time. If you have already created MVC 1.0 applications, they're automatically upgraded to MVC 2 in VS 2010 with an upgrade wizard. And you can start learning and using it absolutely free! Look for MVC 2 in Visual Web Developer 2010 Express.

Never doubt that MVC - which stands for "Model View Controller" is a whole new way of creating ASP.NET web pages, at least for Microsoft. Gone is the concept of "event subroutine". An MVC URL doesn't even point to a ".aspx" file. In MVC, a "controller" refreshes "views" whenever the "model", which has all the data, changes "state". The classic example is the number of items in a shopping cart. The model is the shopping cart. It might be updated when a customer adds an item or when some process at the server determines that an item is not in inventory. The controller notifies all the views and they refresh themselves.

Microsoft didn't invent MVC. It actually goes back to the 1970's and Xerox Parc. (Doesn't everything? The world hasn't seen such a massive missed opportunity since Portugal sent Columbus packing to Spain.) A Norwegian named Trygve Reenskaug invented it. Wikipedia lists 18 different implementations, including .NET. Possibly the one that has received the most rave notices is "Ruby on Rails". There's nothing like the hot breath of competition to catch the undivided attention of Microsoft.

Possibly the best introduction to MVC can be found in Steven Sanderson's Apress book, Pro ASP.NET MVC Framework. (ISBN-13: 978-1430210078). Chapter 1 has an excellent discussion of just why MVC is a better idea. It's a much more convincing and readable than the marketing/techno/legalese found on Microsoft's pages. Since ASP.NET MVC 2 is now standard in Visual Studio 2010, look for new books to just pour off the presses. Within a couple of months of April last year, about half a dozen were published. Sanderson's new version is due out around the first of June.

And finally, for everybody groaning about another forced conversion to a whole new way of writing code, MVC and WebForms run side by side, even in the same application. So do MVC 1 and MVC 2 applications. So you can mix and match if you decide to. (Although that might not be the best development strategy.) Microsoft VP Scott Guthrie is the guiding light at Redmond for MVC and this is what he says about it:

"If you don't like the MVC model or don't find it natural to your style of development, you definitely don't have to use it. It is a totally optional offering - and does not replace the existing WebForms model. Both WebForms and MVC will be fully supported and enhanced going forward."

One of Microsoft's great strengths is that when they decide to go in a new direction, they can accelerate out of the turn better than anybody. If you want to learn more, there's a ton of information and instruction at Microsoft's MVC site:

http://www.asp.net/mvc/

Comments
May 2, 2010 at 5:05 am
(1) Lars Persson :

I’m confused. Isnīt MVC more of a pattern then a technology?

I remember using MVC even when we were coding in ASP.NET 1.1.

May 2, 2010 at 9:49 am
(2) Dan Mabbutt :

It was certainly a pattern before it was a ‘Microsoft’ technology. The difference is that there are templates in VS 2010 and a new library. You could always code the pattern manually and other vendors have supported it for years.

That’s kinda like saying, “Hey! Computers aren’t new. Charles Babbage made one in 1822!”

May 2, 2010 at 1:33 pm
(3) Lars Persson :

Ok, I didn’t try to prove you wrong: :-)
I was only confused about it.

So I suppose that Microsoft have made it simpler to use the MVC-pattern by new technology?

May 2, 2010 at 10:53 pm
(4) Dan Mabbutt :

Yep. Microsoft has added capability to .NET that makes it a lot easier.

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>
Related Searches new toys mvc

©2012 About.com. All rights reserved.

A part of The New York Times Company.