Translate

Sunday, July 22, 2012

Introduction to asp.net MVC (theoretical)

What is MVC?

MVC (Model View Controller) is a design pattern that was introduced in 1979. At that time it was called Thing Model View Editor. This pattern separates out the concerns within an application to three parts called Model, View and Controller.

In an MVC application, this is what the Model, View and Controller is meant for

Model: This holds the business logic.

View: This layer holds the markup (layout of the display). It receives data from the controller. It uses that data to generate the HTML response.

Controller: This is the code that interacts with the user. When a request comes in to an application, it first goes to the controller. The controller is the one who decides which model to use and which View to return to the user. It controls everything, hence the name controller.

What is asp.net MVC?

 If you are coming from the java world, you might have used struts web framework for MVC development. Microsoft provided its own framework in a downloadable installation package to facilitate the use of MVC pattern. The installation package includes templates and tools for Visual Studio 2010, it also includes the assembly System.Web.Mvc.dll. The System.Web.Mvc dll contains classes and interfaces that support the ASP.NET Model View Controller (MVC) framework. The use of asp.net mvc makes building asp.net web applications using MVC pattern a lot more easier.

Comparison of asp.net MVC to Webforms.

By the separation of concerns (into model view and editor) as shown above, MVC makes large applications easier to maintain. This is the biggest reason for the use of MVC. Test driven development is easier in MVC. Many developers also like the fact that they have a much more granular level of control (which makes development a little bit more complicated) over the application. As far as performance is concerned, besides the fact that the HTML rendered wouldn't include a viewstate in MVC, there is not much performance gain by moving from webforms to MVC.


1 comment:

Comments will appear once they have been approved by the moderator