Home >Backend Development >C#.Net Tutorial >A brief discussion on MVC and three-tier architecture

A brief discussion on MVC and three-tier architecture

黄舟
黄舟Original
2017-02-23 10:10:053294browse

First, let me introduce the concept of MVC to you:

MVC (Model View Controller) model, view and controller, it is a more widely used structural design model.

Model: It is the data that needs to be displayed in the MVC design pattern. Under normal circumstances, the model needs to read data from the database, save the state of the model, etc., provide data access methods and data maintenance.

View: It is the user interface used to display the data in the model. Generally speaking, the view is the HTML page.

# Controller: It is used to process user input or interactive commands in order to change the state of the model and select the appropriate view to display the corresponding model data.

The working mechanism is shown on the right:

(1) The user makes a request to the controller.

(2) After receiving the user request, the controller requests the model to obtain relevant data.

(3) The model returns the corresponding data to the controller.

(4) The controller sends relevant data to the specified view.

(5) View presents data to the user.

Through the above introduction, I believe that everyone has a certain understanding and understanding of MVC. So what are the similarities and differences between MVC and the three-tier architecture we have studied before? Where is it?

The common points between MVC and three-tier architecture:

The trigger points of MVC and three-tier architecture are the same - layering and decoupling . They all achieve the separation of display and data, greatly reducing the coupling of the system.

But from a professional perspective, MVC has nothing to do with three layers. Three layers are three layers, and MVC is MVC. The only thing that can connect them is the word "three", but from a beginner's perspective, it is easier to understand by putting the two together and distinguishing them.

The difference between MVC and three layers:

It can be said that except for the same, the rest are all different. For details of their respective working mechanisms, please see the figure below:

The UI in the three layers is decomposed into MVC View and Controller, BLL and DAL are merged into Model. In addition, although the three-tier architecture is called a three-tier architecture, we can divide it into multiple layers as needed. Model is also involved in the third layer, but the Model in the third layer is completely different from the Model in MVC. The Model in the third layer is a table entity, while the Model in MVC includes business logic and data access.

Features of MVC for Web Form:

(1) Easy to unit test

( 2) Easy to implement test-driven development

(3) Easy to extend and replace

(4) Support related features in Web Form

(5) The URL is mapped to the controller

Although MVC has some new features for Web Form, MVC cannot replace the traditional Web Form technology, these two technologies are only used in different scenarios and have different advantages and disadvantages. We cannot say one-sidedly which technology is high and which technology is low. Developers need to choose corresponding technology development projects based on their actual situation. The above are some personal understandings of MVC and the three-tier architecture by consulting relevant information. If there are any shortcomings, please criticize and correct them.

The above is a brief discussion of MVC and three-tier architecture. For more related content, please pay attention to the PHP Chinese website (m.sbmmt.com)!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn