Monday 22 July 2013

What is MVC? Advantages and Disadvantages of asp.net MVC framework?



In this article I will explain what is MVC? What are the main advantages and disadvantages of asp.net MVC framework?

MVC is a framework for building web applications using a MVC (Model-View-Controller) design:
  1. The Model represents the application core (for instance a list of database records).
  2. The View displays the data (the database records).
  3. The Controller handles the input (to the database records).
Model: It is the part of the application that handles the logic for the application data. Often model objects retrieve data (and store data) from a database.


               Model objects are the parts of the application that implement the logic for the application's data domain. Often, model objects retrieve and store model state in a database.

              Example: a Product object might retrieve information from a database, operate on it, and then write updated information back to a Products table in a SQL Server database.

View: It is the parts of the application that handles the display of the data. Most often the views are created from the model data.

               Views are the components that display the application's user interface (UI). Typically, this UI is created from the model data.

               An example would be an edit view of a Products table that displays text boxes, drop-down lists, and check boxes based on the current state of a Product object.

Controller: It is the part of the application that handles user interaction. Typically controllers read data from a view, control user input, and send input data to the model.

             Controllers are the components that handle user interaction, work with the model, and ultimately select a view to render that displays UI. In an MVC application, the view only displays information; the controller handles and responds to user input and interaction. For example, the controller handles query-string values, and passes these values to the model, which in turn might use these values to query the database.


ASP.NET MVC


                ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that enables a clean separation of concerns and that gives you full control over markup for enjoyable, agile development. ASP.NET MVC includes many features that enable fast, TDD-friendly development for creating sophisticated applications that use the latest web standards.




Advantages of ASP.NET MVC:

·         Separation of concerns (SoC) • From a technical standpoint, the organization of code within MVC is very clean, organized and granular, making it easier (hopefully) for a web application to scale in terms of functionality. Promotes great design from a development standpoint.

·         Easier integration with client side tools (rich user interface tools) • More than ever, web applications are increasingly becoming as rich as the applications you see on your desktops. With MVC, it gives you the ability to integrate with such toolkits (such as jQuery) with greater ease and more seamless than in Web Forms.

·         Search Engine Optimization (SEO) Friendly / Stateless • URL's are more friendly to search engines (i.e. mywebapplication.com/users/ 1 - retrieve user with an ID of 1 vs mywebapplication/users/getuser.aspx (id passed in session)). Similarly, since MVC is stateless, this removes the headache of users who spawn multiple web browsers from the same window (session collisions). Along those same lines, MVC adheres to the stateless web protocol rather than 'battling' against it.

·         Works well with developers who need high degree of control • Many controls in ASP.NET web forms automatically generate much of the raw HTML you see when an page is rendered. This can cause headaches for developers. With MVC, it lends itself better towards having complete control with what is rendered and there are no surprises. Even more important, is that the HTML forms typically are much smaller than the Web forms which can equate to a performance boost - something to seriously consider.

·         Test Driven Development (TDD) • With MVC, you can more easily create tests for the web side of things. An additional layer of testing will provide yet another layer of defines against unexpected behaviour.

The main advantages of ASP.net MVC are:

1.      Enables the full control over the rendered HTML.
2.      Provides clean separation of concerns(SoC).
3.      Enables Test Driven Development (TDD).
4.      Easy integration with JavaScript frameworks.
5.      Following the design of stateless nature of the web.
6.      RESTful urls that enables SEO.
7.      No ViewState and PostBack events 

Disadvantages of ASP.net MVC are:
  1. It is not easy to understand and code when you need some customization. If you are building based on a 100% mature database, they you are golden. But if you have frequent changes in your database, you may find it annoying to keep building application again and again. It may also break several other parts of your application.
  2. If you are using Silverlight part of it, the data access is limited to Web Services/WCF/ADO.NET Data Services.  You cannot make direct calls via ADO.NET or stored procedures to a database. Also, you may find it hard to learn LINQ as a new technology to access data.



No comments:

Post a Comment