January 2016 ~ MiTechDev.com

Friday, 22 January 2016

What is MVC(Model View Controller)

02:06:00 Posted by raviteja swayampu No comments
ASP.NET MVC(Model View Controller)

What is MVC:
                    Model View Controller is a Design pattern that is used to solve the development problems which occurs during the development of the web applications.before going to learn about the MVC first we have to know what is the design pattern.

MVC is one of three ASP.NET programming models. MVC is a framework for building web applications using a MVC (Model View Controller) design: The Model represents the application core (for instance a list of database records). The View displays the data (the database records).

Design Pattern:
                     Design pattern is a solution for the problems and it is a approach for the better development of application.

Why we need it:
                              In traditional approach of development the dependency is very high.for example developers need to create database before the front end  development if we make any changes to the front end then database will also be modified.To do any modifications for this applications will be difficult.To overcome this Microsoft introduced MVC approach in 2009.

Features of MVC:

-->The size of the page is smaller compared to the ASP.NET webpage size.
-->Development is very easy.
-->Easy routing.
-->More convenient to the client  side frameworks like jquery.
-->Increased performance.
-->Concurrent development.
-->Changes can be done easily due to the SOC(seperation of concern).

In MVC stands for Model,View,Controller




The Model:
                 Model 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.Most often the views are created from the model data.
Typically controllers read data from a view, control user input, and send input data to the model.

Note: the extension of the model file '.cs'.models are nothing but class files that commonly contains the auto implemented properties.


The View:
                View is the parts of the application that handles the display of the data.View are implemented by using plane html.And Microsoft also provides some "Html helpers" to simplify the view development.Later we will discuss about the helpers in another lesson.

Note: file extension is ".cshtml".

The Controller:
                 Controller is the part of the application that handles user interaction (handles the requests from the user).The MVC separation helps you manage complex applications, because you can focus on one aspect a time. For example, you can focus on the view without depending on the business logic. It also makes it easier to test an application.
The MVC separation also simplifies group development. Different developers can work on the view, the controller logic, and the business logic in parallel.

Note: file extension is:".cs"
In MVC to differentiate the other class files controller class is prefixed with the word "Controller".


In next post we will learn how to do crud operations using MVC.