Preliminary understanding of L3 Architecture

Source: Internet
Author: User
Layer-3 architecture (3 -- tier-Application)   What is a three-tier architecture?

The three-tier architecture usually divides the entire business application:Ui interface layer BLL business logic layer, Dal data access layer, model entity Layer. The purpose of differentiation is"High Cohesion and low coupling"Idea.


1. The presentation layer (UI) is the interface that is displayed to the user and what the user sees when using a system.

2. Business logic layer (BLL): operations on the data layer and data business logic for specific problems

3. Data access layer (DAL): This layer directly accesses the database for adding, deleting, modifying, and querying the database.



Why layer?

 

The three-layer structure is mainly usedThe project structure is clearer and the division of labor is clearer. It is helpful for later maintenance and upgrade. It may not improve the performance, because when the subprogram module is not executed, the main program module can only be in the waiting state. This shows that dividing applications into layers will cause some loss in the execution speed during the period. However, from the perspective of team development efficiency, you can feel the effects of different sizes.

 

Note: Layer 3 is neither a. Net patent nor a technology dedicated to databases, prompting a more universal architecture design concept.

 

What is the role of each layer?

 

Why should we apply the business logic layer?

If there is no logon code, you can process the web program in this way,The appearance layer is responsible for the data on the front-end page, and then transmits the data to the middle layer for data processing,For example, formatting to prevent SQL injection. Such data is transmitted to the access layer and then operated with the data, such as matching the database username and password.

 

The intermediate layer has many purposes,For example, to verify user input data and cache the data read from the database, but the actual purpose of ending the business layer is to combine the most basic storage logic of "data access,Form a business rule. For example, a shopping website has the following rule:
The system automatically registers users who shop for the first time on the website. Such a business rule house is the most suitable for intermediate layers.

 

In"Data access layer"Medium, bestDo not show any "business logic". That is to say, ensure the atomicity of function functions in "data access. That is, the minimum and no further score ." The data access layer only stores or reads data.

 

Instance

 

An in-depth understanding of the "three-tier structure" -- Starting from a small restaurant

  

A "three-tier structure" Web application is like a small restaurant.

N table layer, all. aspx pages are like recipes for this restaurant.

N intermediate business layer is like a restaurant waiter.

N data access layer is like a chef in a restaurant.

N. Our website viewers are diners who eat at restaurants ......


 

 

When we went to a restaurant, we had to first read their recipes and then call the waiter to tell him what we wanted. After the service is written down, the chefs will be notified immediately to cook these dishes. After receiving the notification, the chef immediately caught fire and burned the dishes. After a while, the waiter brought a delicious and steaming dish to our table --

When we access a Website Based on the Asp.net technology, we first open An ASPX page. The background program of this ASPX page calls the corresponding functions at the intermediate business layer to obtain the result. The intermediate business layer calls the corresponding functions of the data access layer to obtain the results.

Comparison:




Are these two processes very similar?

 

The difference is that,When you go to a restaurant for dinner, you need to have a waiter. When accessing an Asp.net website, the menu can be used as a waiter by the diners. Return the result to the ASPX page, that is, return the result to the viewer.

 

Object-oriented and practical combination

 

We know that building a bridge requires bricks. We should first prepare bricks to build the bridge, but in order to explain the coherence. We should build a bridge first, and bricks should be used in the construction process.

The U layer is actually a bridge, the C layer is a brick, and the D layer is a raw material (stone, sand). Here we will explain why the U layer references the D Layer (rather than the U layer on C, C to D), because the bridge requires bricks, but also stones and sand.


The entity graph is



 

Rules

The design of a three-layer structure does not mean that the three modules of the project are called three layers: Dal, BLL, and webui. The following problems are the problems in the project.

 

1 is there only a few (or none) SQL statements or stored procedure calls in uilayer, and these statements guarantee that data will not be modified?

 

2. If uilayer is removed, can your project provide all functions at the interface/API level?

 

3 can your dal be connected to other similar projects?

 

4. Can three modules run on different server codes?

 

If not all the answers are yes, the project cannot be regarded as a strictly layer-3 program,Three-tier programs have some rules to be agreed:

 

1. The most critical. The UI Layer can only have the strictest shell,Cannot contain any bizlogic processing process

 

2. The design should start with bllc., The bll layer should have all bizlogic in advance on the API, an object-oriented approach

 

3 whether the data is a simple sqlherper or a mapping classes, you shouldIt has nothing to do with the system to a certain degree of abstraction.

 

4 whether using COM + (Enterprise Server), remoting, WebService or other remote object technologies, whether or not they are actually deployed on different servers during deployment, at least this should be taken into consideration during design. better. multiple servers must be considered as clusters through Server Load balancer.

 

 

The following is a three-tier detailed description of entity classes and MVC.

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.