MVC definition
Model-view-controller: A software architecture model in software engineering that divides software systems into three basic parts: model, view, and controller.
M Model: The core function of the application to manage the data and values used in this module;
V (view) View: The view provides a demonstration of the model, how the management model is displayed to the user, and it is the appearance of the application;
C (Controller) Controller: Responds to user input, manages user and view interactions, and is a hub for connecting models and views.
How MVC Works
MVC is a design pattern that makes it mandatory to separate the input, processing, and output of an application. Using an MVC application is divided into three core parts: model, view, controller. Each of them handles their own tasks.
1. View V
A view is an interface that the user sees and interacts with. For older Web applications, views are an interface of HTML elements, and in modern Web applications, HTML still plays an important role in the view, but new technologies are emerging, including Macromedia Flash and like xhtml,xml/xsl , WML, and some other identity languages and Web services. One big benefit of MVC is that it can handle many different views of your application. There is really no real processing happening in the view, whether the data is stored online or an employee list, as a view, it is simply a way to output data and allow the user to manipulate it.
2. Model M
Models represent enterprise data and business rules. Of the three parts of MVC, the model has the most processing tasks. The data returned by the model is neutral, meaning that the model is independent of the data format, so that a model can provide data for multiple views. Because the code applied to the model can be reused by multiple views only once, it reduces the repetition of the code.
3. Controller C
The controller accepts the user's input and invokes the model and view to complete the user's needs. So when you click a hyperlink in a Web page and send an HTML form, the controller itself does not output anything and do any processing. It simply receives the request and decides which model component is called to process the request, and then determines which view to use to display the returned data.
Advantages of the MVC framework pattern
1, the developer can only focus on the entire structure of one of the layers;
2, can easily use the new implementation to replace the original level of implementation;
3. Can reduce the dependence between layer and layer;
4, in favor of standardization;
5, facilitate the reuse of the logic of each layer.
Disadvantages of the MVC framework pattern
1. Increase the complexity of the system structure and implementation. For a simple interface, strict adherence to MVC, which separates the model, view, and controller, increases the complexity of the structure and may result in excessive update operations and reduced operational efficiency.
2. The connection between the view and the controller is too tight. Views and controllers are separated from each other, but they do have a tight connection, the view has no controller, its application is very limited, and vice versa, which prevents them from being reused independently.
3. View low-efficiency access to model data. Depending on the model operator interface, the view may need to be called multiple times to obtain sufficient display data. Unnecessary frequent access to unchanged data will also compromise operational performance.