Model–view–controller (usually known as MVC) is an architectural pattern commonly used for developing user interfaces which divides the related program logic into three interconnected components: the model, the view, and the controller.
Each of the MVC components are built to handle specific development aspects of an application. MVC is one of the most frequently used industry-standard web development framework to create scalable and extensible projects.
Features of MVC
- Easy, Highly testable, extensible and pluggable framework
- Offers full control over your HTML as well as your URLs
- Leverage existing features provided by ASP.NET, JSP, NodeJs, etc.
- Clear separation of logic: Model, View, Controller. Separation of application tasks viz. business logic, Ul logic, and input logic.
Following are the components of MVC −
Model : The central component of the pattern. It is the application's dynamic data structure, independent of the user interface.It directly manages the data, logic and rules of the application.It represents data that is being transferred between controller components or any other related business logic. For example, a Controller object will retrieve the customer info from the database. It manipulates data and send back to the database or use it to render the same data.
View : A View is that part of the application that represents the presentation of data. Views are created by the data collected from the model data. A view requests the model to give information so that it resents the output presentation to the user.Any representation of information such as a chart, diagram or table.
Controller : Accepts input and converts it to commands for the model or view. The Controller handles the user interaction. The controller interprets inputs from the user, informing model and the view to change as appropriate.
A Controller send's commands to the model to update its state(E.g., Saving a image). The controller also sends commands to its associated view to change the view's presentation.
Popular MVC web frameworks
Some of the popular MVC frameworks are:
Here are the lists of benefits of MVC architecture
- Simultaneous development – Multiple developers can work simultaneously on the model, controller and views.
- MVC Model component can be tested separately from the user.
- Easy code maintenance easy to extend and grow.
- MVC allows logical grouping of related actions on a controller together.
- Multiple views for a model – Models can have multiple views.
Here are the lists of disadvantages of MVC architecture
- The framework navigation can be complex because it introduces new layers of abstraction and requires users to adapt to the decomposition criteria of MVC.
- Increased complexity and Inefficiency of data
- There is a need for multiple programmers to conduct parallel programming.
- Knowledge on multiple technologies becomes the norm. Developers using MVC need to be skilled in multiple technologies.
- The MVC is an architectural pattern that separates an application into 1) Model, 2) View and 3) Controller
- Model: It includes all the data and its related logic
- View: Present data to the user or handles user interaction
- Controller: An interface between Model and View components
- MVC is a highly testable, extensible and pluggable framework.