) Understanding Dal, BLL, and usl in ASP. NET.

Source: Internet
Author: User

I. Three-tier architecture 1. Presentation layer (USL): it mainly represents the Web mode, or the winform mode. If the logic layer is powerful and complete, the logic layer can provide complete services regardless of how the presentation layer is defined and changed.
2. Business logic layer (BLL): This layer is mainly used to operate on specific problems. It can also be understood as an operation on the data layer to process the data business logic. If the data layer is a building block, the logic layer is the building of these building blocks.
3. data access layer (DAL): mainly refers to the operation layer for raw data (in the form of storing data such as databases or text files), rather than raw data, that is, data operations, instead of databases, it provides data services for the business logic layer or presentation layer.

Ii. Differentiation
1. Presentation Layer: mainly accept user requests and return data, providing applications for clientsProgram.
2. Business logic layer: it is mainly responsible for the operations on the data layer, that is, the combination of some operations on the data layer.
3. Data access layer: it mainly depends on whether your data layer contains logical processing. In fact, its functions mainly perform various operations on data files, without having to worry about other operations.
Iii. Summary
A layer-3 structure is a strictly hierarchical method, that is, the data access layer can only be accessed by the business logic layer, and the business logic layer can only be accessed by the presentation layer. Users send requests to the business logic layer through the presentation layer, the business logic layer completes the relevant business rules and logic, accesses the database through the data access layer to obtain data, and then returns the data in reverse order to display the data in the presentation layer. Some layer-3 structures also include other layers such as factory and model, which are actually an extension and application (add by 51 aspx) based on the layer-3 structure ).

 

 

 

 

About

The three-tier architecture (3-tier Application) generally divides the entire business application into: presentation layer (UI) and business logic layer (BLL) data access layer (DAL ). The purpose of hierarchy differentiation is the idea of "high cohesion and low coupling.

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

2. Business logic layer (BLL): operations for specific problems can also be said to be operations on the data layer and data business logic processing.

3. Data access layer (DAL): transactions made at this layer directly operate on the database and add, delete, modify, and query data.

Overview

In the software architecture design, hierarchical structure is the most common and important structure. The hierarchical structure recommended by Microsoft is generally divided into three layers: data access layer, business logic layer (or domain layer), and presentation layer.

Three-layer structure principle:

The main functions and business logic of the system are processed at the business logic layer.

The so-called three-tier architecture adds an "intermediate layer" between the client and the database, also known as the component layer. The layer-3 system mentioned here does not refer to the layer-3 physical architecture, instead of simply placing three machines as the layer-3 architecture, or not just B/S applications as the layer-3 architecture, layer 3 refers to the logic layer 3, even if these three layers are placed on one machine.

Applications in the layer-3 system put business rules, data access, and legality verification into the middle layer for processing. Normally, the client does not directly interact with the database, but establishes a connection with the middle layer through COM/DCOM communication, and then interacts with the database through the middle layer.

Presentation Layer

Located in the outermost layer (top layer), closest to the user. It is used to display data and receive user input data, providing users with an interactive operation interface.

Business logic layer

The business logic layer is undoubtedly part of the system architecture that reflects the core value. Its focus is mainly on the formulation of business rules, the implementation of business processes, and other system designs related to business needs, that is, it is the domain that the system is dealing) logic is related. In many cases, the business logic layer is also called the domain layer. For example, in the book patterns of enterprise application architecture, Martin Fowler divides the entire architecture into three main layers: presentation layer, domain layer, and data source layer. Eric Evans, a pioneer in the field-driven design, divided the business logic layer into the application layer and the domain layer in detail, the solution of domain logic and domain logic is further separated by hierarchy.

The business logic layer is critical to the architecture. It is in the middle of the data access layer and the presentation layer, and plays a role in data exchange. Because the layer is a weak coupling structure, the dependency between the layer is downward, and the underlying layer is "ignorant" for the upper layer, changing the design of the upper layer has no impact on the underlying layer of its calls. If the hierarchical design follows the interface-oriented design idea, this downward dependency should also be a weak dependency. Therefore, without changing the interface definition, the ideal layered architecture should be a "drawer" architecture that supports extraction and replacement. Because of this, the design of the business logic layer is critical to an architecture that supports scalability, because it plays two different roles. For the data access layer, it is the caller; for the presentation layer, it is the caller. Dependencies and dependencies are all entangled in the business logic layer. How to decouple dependencies is a task left to designers apart from implementing business logic.

Data Layer

Data access layer: it is also known as the persistent layer. Its function is mainly to access the database, including the database system, binary files, text documents, and XML documents.

Simply put, select, insert, update, and delete operations on data tables are implemented. If you want to add an ORM element, it will include mapping between the object and the data table, and object Object persistence.

Advantages and disadvantages

Advantages:

1. developers can only pay attention to one of the layers in the entire structure;

2. It is easy to replace the original implementation with the new implementation;

3. The dependency between layers can be reduced;

4. conducive to standardization;

5. facilitate the reuse of logic at each layer.

Disadvantages:

1. Reduced system performance. This is self-evident. If the hierarchical structure is not used, many businesses can directly access the database to obtain the corresponding data, but now it must be done through the middle layer.

2. Cascade modifications may sometimes occur. This kind of modification is especially reflected in the top-down direction. If you need to add a function in the presentation layer, to ensure that the design conforms to the hierarchical structure, you may need to add a corresponding function in the corresponding business logic layer and data access layer.Code.

Rules

The three-tier program does not mean that the project is divided into three modules: Dal, BLL, and webui. The following are some questions about your project:

1. There are 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 transplanted to other projects in similar environments?

4. Can three modules run on different servers?

If not all the answers are yes, your project cannot be regarded as a strictly layer-3 program. The layer-3 program has some rules that need to be agreed:

1. Most importantly, the UI Layer can only serve as one shell and cannot contain any bizlogic processing process.

2. The design should start with Bll, not the UI. The bll layer should implement all bizlogic on the API, in an object-oriented way.

3. Whether the data layer is a simple sqlhelper or a mapping classes, the system should be unrelated to a certain degree of abstraction.

4. whether using the remote object technologies such as COM + (Enterprise Service), remoting, or WebService, whether or not they are actually deployed on different servers during deployment, at least we should consider this in design. Further, we must consider using multiple servers as clusters through Server Load balancer.

Therefore, when considering whether a project should apply a three-tier/multi-tier design, do you have to consider whether it is really necessary? In fact, it is enough for most programs to open a webapplication, and there is no need to make such a complicated one. The multi-layer structure is used to solve the real complex project requirements.

Differences from MVC

MVC (Model-View-Controller) is a design pattern that we can use to create a distinction between a domain object and a UI presentation object.

They also have an architecture level. The same thing is that they all have a performance layer, but they are different from the other two layers.

The concept of controler is not defined in a three-tier architecture. This is what I think is the most different. MVC does not regard the logical access of the business as two layers, which is the main difference between building a program using a three-layer architecture or MVC. Of course. Model is also mentioned in Layer 3, but the concept of Model in Layer 3 architecture is different from that in MVC. The typical model layer in Layer 3 architecture is composed of entity classes, in MVC, it is composed of business logic and access data.

This article is transferred from Boyuan http://www.cnblogs.com/xianspace/archive/2008/12/13/1354482.html

 

Related Article

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.