Three-tier architecture and MVC pattern _ architecture

Source: Internet
Author: User
1, three-tier architecture

The three-tier architecture of the three-tier architecture (3-tier application) is to divide the entire business application into the presentation layer (UI), the Business Logic layer (BLL), the data Access Layer (DAL). The purpose of distinguishing hierarchy is to think of "high cohesion, low coupling".

1, the performance layer (UI): Popular speaking is to show the user interface, that is, the user in the use of a system when he saw the proceeds.

2, Business Logic Layer (BLL): The operation of specific problems, it can be said that the operation of the data layer, the data business logic processing.

3, data access Layer (DAL): This layer of transactions directly operating the database, for data additions, deletions, modifications, updates, search and so on.


Presentation layer implementation of the representative works is a struts framework, the business layer to achieve the representative works is spring, the persistence layer to achieve the representative works is hibernate.

As an example:

The persistence layer is removed from the persistent library-10.

The business layer is translated to 10 degrees Celsius according to certain logic (here we take the logic of the temperature for example).

The presentation layer appears to the user "gee, it's so cold today." ”。

Layer is the equivalent of a black box, we do not have to know how to implement it inside, just need to know how to call it on the line. Each layer deals only with the two tiers of the upper and lower adjacent layers. When a layer of internal due to changes in technology, as long as the interface does not change, the other layer does not have to make any changes. Increased flexibility after tiering, but also facilitate the team division of Labor Development.


2, MVC 2.1 standard MVC (Model-view-controller)

Model: A data model that provides the data to be presented, thus containing data and behavior that can be considered domain model (domain) or JavaBean components (including data and behavior), but is now generally separated: Value Object (data) and service layer (behavior). That is, the model provides the function of model data query and the status update of model data, including data and business.

View: is responsible for the demonstration of the model, is generally what we see the user interface, customers want to see things.

Controller (Controller): Receive user requests, delegate to the model for processing (state change), after processing the returned model data returned to the view, the view is responsible for display. That is to say, the controller does a dispatcher's job.

As we can see from the diagram, in standard MVC, the model can actively push data to update the view (Observer design mode, register view on the model, update the view automatically when the model is updated), but in web development the model is unable to actively push the view (the user interface cannot be actively updated), Because in web development is the request-response model. 2.2 Web MVC

The M (model)-V (view)-C (Controller) concept in Web MVC is the same as the standard MVC concept, so let's take a look at the Web MVC Standard architecture as shown in the following illustration:

In Web MVC mode, the model cannot actively push data to the view, and if the user wants to update the view, it needs to send another request (the request-response model).


M: Model: The core function of the application to manage the data and values used in this module;

V (view) View: Views provide 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 the hub for connecting models and views.

MVC is used to decouple the Web (UI) layer from responsibility


3, three-tier architecture and MVC differences and relationships

MVC is Model-view-controller, strictly speaking, these three add up after the three-tier architecture of the UI layer, that is, MVC in the three-tier architecture of the UI layer again differentiated, divided into the controller, view, entity three parts, the controller completes the page logic, Through the entity to complete the call with the interface layer, while the C-tier directly with the three layer of BLL dialogue.


MVC can be a presentation layer framework in the three layer, which belongs to the presentation layer. Layer three and MVC can coexist.

The three tiers are based on business logic, and MVC is based on the page.

MVC is mainly used for the performance layer, the 3 layer is mainly used for architecture, 3 layer is generally the performance layer, middle layer, data layer, in which the performance layer can be divided into M, V, C, (Model View Controller) models-View-controller


MVC is the mode of expression (presentation pattern)

Three-tier architecture is a typical architectural model (architecture pattern)

The layered model of the three-tier architecture is a typical upper and lower relationship, with the upper layer dependent on the lower level. However, MVC as a mode of expression does not exist the upper and lower relations, but the mutual cooperation relationship. Even if MVC is considered a schema, it is not a layered pattern. MVC and three-tier architectures are basically not comparable and are technologies that apply to different areas.

from:https://my.oschina.net/u/1020238/blog/519767

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.