153-tier architecture

Source: Internet
Author: User
Tags md5 hash

Why should there be a three-tier architecture???  
    1. The waiter only needs to be responsible for receiving guests
    2. Cooks only need to cook food.
    3. Buyers only need to be responsible for sourcing ingredients
 

Which layer changes occur, only the layer needs to be changed, and the entire system needs not be changed.

Clear division of labor level clear, low coupling between each layer-improve efficiency, adapt to demand changes, maintainability is high, scalability is high.

Three-tier architecture (3-tier architecture)

The three-tier architecture in its usual sense is to divide the entire business application into:

The presentation layer (Presentation layer), the business logic layer, and the data access layer.

The purpose of distinguishing hierarchy is to think of "high cohesion and low coupling"

In the design of software architecture, layered structure is the most common and most important structure. Generally divided into three layers, from bottom to top respectively: The data access layer, the business logic layer (or also called the domain layer), the presentation layer.

Build a three-tier architecture

UI (presentation layer):

The main point is the interface of user interaction. Used to receive data entered by the user and to display the data needed to process the user.

BLL (business logic Layer):

A bridge between the UI layer and the DAL layer. Implement business logic. Business logic specifically includes: validation, calculations, business rules, and more

DAL (data access Layer):

Dealing with databases. The main realization of the database of the increase, deletion, change, check. Submits the data that is stored in the database to the business layer. (These operations are, of course, based on the UI layer.) The user's needs are reflected to the interface (UI), the UI is reflected to the BLL,BLL reflected to the dal,dal for data manipulation, and then one by one returns until the user needs the data feedback to the user)

Model class

    • The model is not a layer and is the object of data transfer between layers.
    • Implementation of "encapsulation" in object-oriented thinking
    • Pass through the three layers, passing data between three layers, to be sure that the solid layer runs through the three layers to connect the three layers
    • The data transfer (unidirectional) between each layer (Ui->bll->dal) is passed by a variable or entity as a parameter, which constructs the connection between the three layers and accomplishes the function.
    • For beginners, it is understandable that each data table corresponds to an entity, that is, the attributes in the field corresponding to the entity in each data table.

Three-layer and entity-level dependencies:

Thought comes from life:

MD5

MD5 (message-digest algorithm 5) message digest algorithm

MD5 algorithm is a hash (hash) algorithm (digest algorithm, fingerprint algorithm), not a cryptographic algorithm (Error-prone). Any content of any length can be computed with MD5 hash value.

MD5 length is generally 32 bits of the 16 binary string ( such as 71f396e4134a1160d90bb1439876df31), the number of MD5 is limited, but the data source is infinite, so there are different content to produce the same MD5 value probability. Therefore, the MD5 algorithm is irreversible, that is, the content corresponding to the MD5 value can not be reversed by the MD5 value of the content. But the same MD5 that are generated for different content is very, very low probability.

three-tier architecture benefits

Decoupling
Division of labor, developers can focus on a layer

Portability, modular design, reusability

Support for Distributed systems (network-based)

Scalable, MSSQL, and Oracle switching

Level Three:

UI Layer

The BLL layer (the Business logic layer, gets the UI layer of data that returns what the UI needs .) Cannot appear MessageBox, TextBox, etc.)

The DAL layer (datetable, etc. should be in the DAL instead of returning to the DataTable, returning the Model Class (entity Class))

Three Floor summary

1. UI (User Interface)

2, the BLL layer is the specific business logic operation

3, the DAL layer only SQL statements and data processing, the other layer should not normally appear in SQL statements and the related classes of ADO. The BLL is simply calling the DAL, but the BLL layer is not soy sauce: The data check should be put into the BLL, and the BLL will combine the DAL into a new operation, such as changing the password (getting the current password, verifying it, and updating the password to the database if it matches)

4, Model is the data transfer between the three layers. The UI layer calls the BLL, the BLL calls the DAL, the data is passed with Model, and the UI cannot call the DAL directly. Model is not a layer, it is a data entity

Three-tier architecture will generally be slower than non-layered, but three-layer division is clear, can improve development efficiency, sacrificing a little performance is also possible, many times the efficiency of the program may not be the only pursuit of factors (not that the program performance is not important, according to actual development)

Code Generator

Each time you write three layers of three classes and the Model class, it is repeated write, the code is similar, so you can use the code generator automatically generated. We can write our own code generator for our own use (Only you know what you need)

Although we can use the code generator to generate three layers of code, but we must learn from the beginning to manually write three-layer architecture code , until we can skillfully write three-layer architecture code to use the code generator (to understand the principle, only understand the three-tier architecture model , In order to better use the code generator, because some code generators do not meet the actual requirements or to modify their own)

153-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.