PDC 2008: First in-depth look at ASP.NET MVC
At Day 1 of PDC 2008 in Los Angeles, attendees got their first look at a technology Microsoft introduced earlier this month into beta: a new way for building reformed Web applications.
The Web site StackOverflow.com is the latest example of a fully operational Web site, running today out of beta, using a technology from Microsoft that is still in beta: ASP.NET MVC, the new compartmentalization model for content-driven Web site programming.
This afternoon, Microsoft senior program manager Phil Haack showed attendees how many of the functions of StackOverflow could be essentially duplicated -- or shamelessly ripped off -- in about the time it takes to give a talk at PDC. StackOverflow takes comments from developers who are searching for solutions to specific problems; the content of the site, therefore, is like a BBS. It's made up principally of comments from users, who may not necessarily be members. Using ASP.NET MVC, a developer can generate complex queries that produce models of the underlying data. Those models can then be processed using views, which render the comments in very clean HTML code that can be cleaned up using CSS.
ASP.NET MVC
An extension to ASP.NET that enables Web developers to make their work more sensible and extensible by compartmentalizing the functions of managing and displaying content into three discrete actors: the model, the view, and the controller.
For the Visual Studio programmer, ASP.NET MVC is a new Web Application Project (WAP) type. Once engaged, it enables him to build the controller, which is effectively the producer of the content of the Web page. Its job is to process requests from the user; through those requests, the controller generates the model of the data for the site. This is the type of content for which sites rely on content management systems of one form or another; here, the controller performs the management functions at the code level.
At runtime, the user requests result in the controller creating views of the data. How the site displays those views depends on specific view modules which are named for each view. The product is pure HTML, though CSS can (and obviously should) be employed to enable formatting; JavaScript scripts may also be helpful.
The absolute division of labor in the development of a content-driven Web site could easily drive down development time. That said, the use of MVC in ASP.NET is nowhere near automatic; its senior program manager at Microsoft, Phil Haack, compared the differences between programming in ASP.NET 3.0 and ASP.NET MVC to driving a manual transmission and an automatic. With a stickshift, Haack said, you have more driving fun, but you have to pay more careful attention to how your brakes are set and what your RPM is -- factors on a much lower level.
For Microsoft, ASP.NET MVC helps score more points with the open source community -- which have contributed ideas to the project, as well as JavaScript scripts that Microsoft tends to use with it (jQuery being one of them); and the standards community which welcomes (or at least should welcome) the trend toward sensibility and practicality. It's also a low-intensity project that requires a minimal development team at the company (Haack works with just a handful of other people), that has a maximal payoff in terms of visibility and developer interest.