MVC schema Pattern ( model - View - controller mode )
MVC was originally used to build the user interface in smaltalk_80. m represents the model,v represents the view, andC represents the controller controllers .
By putting together the components of duties and attributes, and isolating them in a similar way,MVC decomposes the system into three parts: model, view, and controller, each of which is relatively independent and has a single responsibility, and can focus on its core logic in the realization process. MVC is a kind of rational carding and slicing of system complexity, its thought essence is "separation of concerns".
The purpose of MVC is to increase the reuse rate of code and reduce the coupling of data representation, data description, and application operations. It also makes software maintainability, maintainability, scalability, flexibility, and encapsulation much better.
Model layer, which can be simply understood as the data layer, is used to provide data. In the project, (simple understanding) the data access and operation, such as the object-relational mapping code as the model layer, that is, the operation of the database of the columns of code as the model layer. For example, we will write the DAO type code in the code, this DAO can be understood as the code that belongs to the model layer.
The view layer, which is the UI interface, is the ability to interact with the user. Generally all the JSP,HTML and other pages is the view layer.
Controller control layer,the function of the controller layer is to associate the model and the view layer. For example, the view is mainly to display the data, but the data need Model to access, so that theview will tell the controller, and then controller to tell model, After the model requests the data, tell the View again.
It's easy for many to confuse MVC with the three-tier architecture model, but there's a big difference between them.
The three-tier architecture (3-tier application) typically has a three-tier architecture that divides the entire business application into:
Presentation layer (UI): The interface that is presented to the user
Business Logic Layer (BLL): For the operation of the specific problem, it can be said that the operation of the data layer, the data business logic processing
Data Access Layer (DAL):: This layer of transactions directly manipulate the database, for data additions, deletions, modifications, updates, lookups, etc.
In strict terms, mvc (model-view-controller) Three adds up to the UI layer in the three-tier architecture , meaning that MVC splits theUI layer in the three-tier architecture again into a controller, view, Entity three parts, the controller completes the page logic, through the entity to complete the call with the interface layer, and the m layer directly with the BLL in the three layer dialogue.
MVC is the architecture of the presentation layer, andMVC's model is actually ViewModel, which is the data for the view to show. ViewModel does not contain business logic, nor does it contain data reads. In the n-tier architecture, there is usually a model layer that corresponds to the database table, which is called the O in Orm . This model may be POCO, or it may be an entity class that contains some validation logic, and generally does not contain data reads. Data is read by the data access layer. MVC, as the UI layer , typically does not manipulate the data access layer directly, and there is a business logic layer that encapsulates the business logic and invokes the data access layer. The UI layer (Controller) obtains the data (Model) through the business logic Layerand encapsulates (ViewModel), then selects the appropriate View.
MVC schema Pattern