Three-tier architecture

Source: Internet
Author: User

The software that runs on the c\s server can be of this style


This is a typical two-layer structure, characterized by:

1. Database access and user-type judgment logic is implemented together

2. User interface layer calls data access implementation directly

3. The entire system function is implemented in the same project

4. Conduct business rules, legality verification and other work

Although it seems to be relatively concise, but in practice there are many problems: if the user's needs change, the application needs to make a lot of changes, and even need to re-development, to the system maintenance and upgrade caused great inconvenience; The user interface directly accesses the database, which brings a lot of database information security hidden trouble.

In order to overcome the problems caused by two-layer structure, three-layer structure system has been developed. The so-called three-layer structure system is to add a few middle layers between the client and the database, the client and the database server separated, the middle layer contains the business logic layer, the data access layer and the data object model layer, is to split the function of the client in the two layers, is a logical three-layer structure.


The three-layer structure embodies the idea of program differentiation, and it is not necessary to modify the whole program for a certain aspect, which reduces the cohesion, enhances the reusability of the Code, and facilitates the distributed application under different network environments. Three-tier structure: The display layer (UI), the Business Logic layer (BLL), the data Access Layer (DAL), and the core is the business logic layer.


Features of the display layer: 1. Displaying specific business data to the user, 2. Capturing the user's input information and operations; 3. The interface that is presented to the user, which is what the user sees when he or she uses a system. Design principles: User first, friendly interface, both concise.

The role of the business logic layer: fetching data from the Dal for UI display, obtaining user directives and data from the UI, executing business logic, fetching users and data from the UI, writing to the data source via the DAL, receiving instructions or data input from the user, submitting to the application layer for processing, It is also responsible for displaying the processing results of the business logic layer to the user. The business logic layer has less resource requirements for hardware than the traditional way of application. Responsibility mechanism: Ui->bll->ui;ui->bll->dal->bll->ui, that is, the DAL assembly does not refer to the BLL and UI; TheBLL needs to reference the DAL;theUI directly references the BLL , the DAL may be referenced indirectly.

Data Access Layer role: mainly responsible for database access, access to the database system, binary files, text documents or XML documents, to achieve data manipulation of the data table. The data access layer is not a database, it is the operation of the raw data in the database, is to provide data services for the business logic layer or the presentation layer.

Specific application principles:

The DAL provides only basic data access and does not contain any business-related logic processing;

The UI is only responsible for displaying and capturing user actions, and does not include any business-related logic processing;

The BLL is only responsible for processing the business logic, by obtaining the operation instructions from the UI, deciding to execute the business logic and handing it over to the DAL when it needs to access the data source. After processing is complete, return the necessary data to the UI.

Not all software development to use the three-tier structure, when the development of software is very simple, or no real data storage layer is divorced from the use of the database, this time there is no need to use a three-layer structure to complicate the simple problem, contrary to the development of software logic is very complex or need database support, It is necessary to consider a three-layer structure to simplify the development difficulty. In fact, the three-layer structure and two-layer structure can achieve the same function, but the structure of the three layer more decoupling, each module more high cohesion low coupling, but also can greatly reduce the complexity of software development problems, conducive to the smooth development of software. The three layer is very useful and will be used in more depth to summarize the usage of the three layers.

Three-tier architecture

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.