The design pattern of the MVC (Model View Controller) has been around for a few decades and has been used in a variety of technologies. All from Smalltalk to C++ to Java, and now C Sharp and.NET use this pattern to create a user interface.
Some important features of the MVC pattern are provided below.
- In 1979 it was originally named Thing-Model-View-Editor and subsequently simplified to Model-View-Controller.
- It is a powerful and elegant way to separate issues within an application (e.g. to separate data access logic from display logic) and is extremely well applicable to web applications.
- The explicit separation of concerns adds a little extra complexity to the design of an application, but the extraordinary advantages outweigh the extra effort.
The MVC architectural pattern separates the application’s user interface (UI) into three main parts.
- The Model ? A set of classes describing the data with which you work and the business logic.
- The View ? Defines how to display the application’s UI. It’s a pure HTML that decides how the UI looks.
- The Controller ? A set of classes that handle user communication, application flow and application logic.
MVC Idea Behind
The idea is that you have a component called the view, which is solely responsible for making this user interface HTML or UI widgets for a desktop application. The view talks to a model and the model contains all the data to display the view.
Views don’t usually have much logic inside them. In a web application, the view may have no code at all associated with it. It could only have HTML and then some expressions of where you can take pieces of data from the model and plug them into the right places inside the HTML template that you have built.
The controller that organizes this is all. When an HTTP request for an MVC application arrives, the request is routed to a controller and the controller has to talk to either the database, the file system or the model.