Step by step. NET three-tier Architecture Analysis 1. What is a three-tier architecture

Source: Internet
Author: User

During project development, the entire project is sometimes divided into three layers, including the presentation layer (UI), business logic layer (BLL), and data access layer (DAL ). The role of Layer 3 is as follows:
Presentation Layer: provides an interactive operation interface for users. This is true for both Web and WinForm. The interface that our website displays to users.

Business logic layer: responsible for key business processing and data transmission. Complex logic judgment and data verification involving databases must be processed here. Return the desired value or process related logic based on the input value.

Data access layer: This layer is known and responsible for accessing database data. It mainly provides data for the business logic layer, and operates databases based on input values, such as adding, deleting, modifying, or other data.

The following describes the next user management module:

To facilitate the development of the entire project, we will create several Class Libraries SQLHelper, BLL, DAL, Model and a Web site in the project. To name the project clearly, we can name the three projects (Class Libraries added in the solution) as follows ):

Business logic layer: BLL. The namespace is set to BLL by default.

DataAccessLayer: DAL. The namespace is set to DAL by default.

SQL help class: SQLHelper. The namespace is set to SQLHelper by default.

In addition, we usually add another class library to facilitate data transmission. This class library runs through the entire three-tier architecture. Entity class. The namespace is usually named "Model" and the default value is "Models. Each encapsulated class corresponds to an object, which is usually a table in the database. For example, if the user table (custom) in the database is encapsulated as (custom), each field in the table is encapsulated as a common attribute.

In this way, the construction of the three-tier architecture is basically complete. These three layers have very strong dependencies:

Presentation Layer ‑ business logic layer ‑ data access layer

Data transmission between them is bidirectional, and data is usually transmitted through the entity class.

What are the advantages of the three-tier architecture:

1. Easy Project Modification and maintenance. During project development or after development, or even during project migration. This three-tier architecture is very convenient. For example, to migrate a project from Web to Form, we only need to repeat the presentation layer. The remaining two layers do not need to be changed. You only need to add them to the existing project. If this architecture is not used, the code is only written to the presentation layer. Then almost all the codes will be re-submitted.

2. Easy to expand. This is also true for function extensions. If you want to add a function, you only need to add the method of the original class library.

3. Easy code reuse. This does not need to be explained.

4. Easy division of labor and collaboration

You can also add an interface class library Iinterface to the design mode to make your code more flexible and of higher quality.

The next step is to explain the database design. Please click it.

 

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.