The differences between the three-tier architecture and the MVC architecture are: the architecture of the three-tier architecture is linear, and MVC is triangular; in terms of hierarchy, each layer in the three layers is separated from the network, while each layer of MVC is separated from the network. are related; three-tier is the architectural style, MVC is the architectural design pattern
The concept of three-tier architecture looks similar to the concept of MVC;, but from some aspects, it also has many differences, Next, in the article, we will introduce the differences between the two in detail, which has certain reference value and I hope it will be helpful to everyone.
【Recommended course: MVC Tutorial】
The difference between three-tier architecture and MVC architecture
(1) Topology
Basic rules in three-tier architecture is that the client never contacts the third layer directly, in the three layer model all communication has to go through the middle layer i.e. its architecture is linear whereas in MVC architecture it is triangular and the view will relay the commands to the controller, the controller updates the model, and the view updates from the model in a direct manner
(2) Hierarchical aspect
Each Applications have one or more presentation layers, business logic layers, and data access layers
In the three-tier model, each layer is usually separated from the network, the presentation layer is located on some server, and then Communicates with the backend application server on the network, which in turn communicates with the database server on the network.
MVC is a programming design pattern in which different parts of the logic are responsible for displaying models, views, and controllers in an application. These things are related because for example the Model layer may have an internal implementation that calls the DB to save and get data. The controller can reside on the web server and remotely call the app server to obtain data.
(3) Communication aspect
Communication in the three layers: The three layers only refer to the physical structure of the implementation, These are sometimes confusing because the MVC design pattern is usually implemented using a 3-tier model.
Communication in MVC: In MVC combined weights we can say that with one-way communication each layer is modified by the one on the left and in response the one on the right is updated, left and right Just a demonstration.
(4) Usage aspects
In larger applications, MVC is the presentation layer of the N-tier architecture. Models, views and controllers are only used to populate the model with data from the data layer. MVC can also be used as a complete three-tier architecture for view presentation, with the controller being the business logic and the model being the data access layer. Three layers are architectural styles, and MVC is an architectural design pattern, which leads to differences between them. But we can use MVC design pattern in three-tier model.
Summary: The above is the entire content of this article, I hope it will be helpful to everyone.
The above is the detailed content of What is the difference between three-tier architecture and MVC?. For more information, please follow other related articles on the PHP Chinese website!