Fri Feb 01 2019
What is MVC framework?
Model View Controller or MVC is a software architectural pattern for implementing user interfaces on computers. It is an architectural pattern that separates an application into three main logical components: the model, the view, and the controller. The MVC design pattern decouples these major components allowing for efficient code reuse and parallel development. Each of these components are built to handle specific developmentaspects of an application. MVC is one of the most frequently usedindustry-standard web development framework to create scalable andextensible projects.
As with other software architectures, MVC expresses the "core of the solution" to a problem while allowing it to be adapted for each system. Following are the components of MVC -
Model
The Model component corresponds to all the data-related logic that the user works with. A model stores data that is retrieved according to commands from the controller and displayed in the view. It’s where the main logic and the data objects that constitute the core functionality of the application are developed. The model is responsible for getting data from a database, packaging it in data objects that can be understood by other components, and delivering those objects - most of which will happen in response to input from the controller.
View
The View component is used for all the UI logic of the application. It generates new output to the user based on changes in the model.
Controller
Controller represents the classes connecting the model and the view and is used to communicate between classes in the model and view. It process all the business logic and incoming requests, manipulate data using the Model component and interact with the Views to render the final output.
Let's take a look at how the execution of an MVC application takes place when there is a certain request from the client.
Firstly, the client browser sends a request to the MVC Application.
Then global.ascx receives this request and performs routing based on the URL of the incoming request using the RouteTable, RouteData, UrlRoutingModule and MvcRouteHandler objects.
Next, this routing operation calls the appropriate controller and executes it using the IControllerFactory object and MvcHandler object's Execute method.
The Controller processes the data using Model and invokes the appropriate method using ControllerActionInvoker object.
The processed Model is then passed to the View, which in turn renders the final output.
Why use an MVC Framework?
MVC frameworks do most of the basic scaffolding work of building an MVC application. Developers simply have to extend the structure provided by the framework. Developers can focus on building the main logic of their applications and the interfaces through which users will interact with that logic, rather than having to worry about the complex business of organizing the components and how they will interact.
Traditionally used for desktop graphical user interfaces (GUIs), this architecture has become popular for designing web applications and even mobile, desktop and other clients. Popular programming languages like Java, C#, Python, Ruby, PHP have MVC frameworks that are used in web application development.