Wednesday, October 10, 2012

What is dotNet MVC

When ASP.NET 1.0 was fi rst released in 2002, it was easy to think of ASP.NET and Web Forms as
one and the same thing. ASP.NET has always supported two layers of abstraction, though:
‰ System.Web.UI: The Web Forms layer, comprising server controls, ViewState, and so on
‰ System.Web: The plumbing, which supplies the basic web stack, including modules, handlers,
the HTTP stack, and so on
The mainstream method of developing with ASP.NET included the whole Web Forms stack — taking
advantage of drag-and-drop controls, semi-magical statefulness, and wonderful server controls
while dealing with the complications behind the scenes (an often confusing page life cycle, less than
optimal HTML, and so on).
However, there was always the possibility of getting below all that — responding directly to HTTP
requests, building out web frameworks just the way you wanted them to work, crafting beautiful
HTML — using Handlers, Modules, and other handwritten code. You could do it, but it was painful;
there just wasn’t a built-in pattern that supported any of those things. It wasn’t for lack of patterns
in the broader computer science world, though. By the time ASP.NET MVC was announced in
2007, the MVC pattern was becoming one of the most popular ways of building web frameworks.


The MVC Pattern
 

Model-View-Controller (MVC) has been an important architectural pattern in computer science for
many years. Originally named Thing-Model-View-Editor in 1979, it was later simplifi ed to Model-
View-Controller. It is a powerful and elegant means of separating concerns within an application
(for example, separating data access logic from display logic) and applies itself extremely well to
web applications. Its explicit separation of concerns does add a small amount of extra complexity
to an application’s design, but the extraordinary benefi ts outweigh the extra effort. It has been used
in dozens of frameworks since its introduction. You’ll fi nd MVC in Java and C++, on Mac and on
Windows, and inside literally dozens of frameworks.
The MVC separates the user interface of an application into three main aspects:
‰ The Model: A set of classes that describes the data you’re working with as well as the business
rules for how the data can be changed and manipulated
‰ The View: Defi nes how the application’s user interface (UI) will be displayed
‰ The Controller: A set of classes that handles communication from the user, overall application
fl ow, and application-specifi c logic
 

MVC AS A USER INTERFACE PATTERN
 

Notice that we’re referred to MVC as a pattern for the User Interface. The MVC
pattern presents a solution for handling user interaction, but says nothing about how
you will handle other application concerns like data access, service interactions, etc.
It’s helpful to keep this in mind as you approach MVC: it is a useful pattern, but
likely one of many patterns you will use in developing an application.

No comments:

Post a Comment