Friday 29 January 2016

What is MVC?

What is ASP.NET MVC?

Do you know what is ASP.NET MVC?

Hi everyone, first of all, I am starting this blog to talk about .NET and things related  for developers and everybody who wants to know more about this universe.

I am going to explain for you what is MVC today, MVC is nothing more than a Design Pattern.

The Model-View-Controller (MVC) architectural pattern separates an application into three main components: the model, the view, and the controller.The ASP.NET MVC framework provides an alternative to the ASP.NET Web Forms pattern for creating Web applications. The ASP.NET MVC framework is a lightweight, highly testable presentation framework that (as with Web Forms-based applications) is integrated with existing ASP.NET features, such as master pages and membership-based authentication. The MVC framework is defined in the System.Web.Mvc assembly.

Model: Nothing more than a class. Yes, it is just a class, but a class that stores the attributes needed for the application, model has all the business, all the data manipulation. Summing up, model is a class with everything you need to manipulate data.


Simple Mvc Model

View: View is the HTML that users will see, Views uses the Razor Engine, implementing the use of Helpers  (I will write about Helpers soon). You can also use Models to bind the data.



Simple View Code

View in Browser


Controller: Is the middle between Model and View. Receive all the requests from user.


Controller

Let's see a chat with Model, View and Controller:

Controller: Hey Model, user wants to login in LinkedIn, please take these data and validate if is this ok!

Model: This is right, user can login.

Controller: Thanks Model. View, the data are right, I am going to send you user's data, and you, please, load the profile page.

View: Thanks, I am loading.


MVC'S Advantages

  • It makes it easier to manage complexity by dividing an application into the model, the view, and the controller.
  • It does not use view state or server-based forms. This makes the MVC framework ideal for developers who want full control over the behavior of an application.
  • It uses a Front Controller pattern that processes Web application requests through a single controller. This enables you to design an application that supports a rich routing infrastructure.
  • It provides better support for test-driven development (TDD).
  • It works well for Web applications that are supported by large teams of developers and for Web designers who need a high degree of control over the application behavior.

When do I use  ASP.NET MVC?

There is no rule to know when you should use MVC or Web Forms, Asp.Net  MVC did not come to replace Web Forms, but to be one more option in Web Development.

5 comments:

  1. very well explained about #MVC, here is another article http://www.technologycrowds.com/2013/10/mvc-vs-webforms.html which explains difference between MVC vs Webforms.

    ReplyDelete
  2. Thanks Ajan, very nice article as well!!

    ReplyDelete
  3. Very nice! Simply explained and straight to the point.

    ReplyDelete
  4. Hello raphael , i like your work , posts to educate and empower , i am a rookie at cording i would like to get from here to where you are one time in life , i have i deas i would like to work on but i don't have the technical know how , kindly if u can assist me in understanding codding languages and working on projects i have it would be a blessing .

    ReplyDelete