. NET three-tier architecture

Source: Internet
Author: User

I hope my friends will leave their understanding of the three-layer architecture ...

Three-tier architecture concept

    1. User Interface Presentation layer (USL)
    2. Business Logic Layer (BLL)
    3. Data access Layer (DAL)


The BLL separates the USL from the Dal and joins the business rules

    • The role of each layer
    • 1: Data access layer: mainly for the original data (database or text files, such as the form of data storage) operation layer, rather than the original data, that is, the operation of the data, rather than the database, specifically for the business logic layer or presentation layer to provide data services.

      2: Business logic Layer: mainly for the specific problem of operation, can also be understood as the operation of the data layer, the data business logic processing, if the data layer is a building block, the logic layer is the building of these blocks.

      3: The presentation layer: The main means of the web, can also be expressed as a WinForm way, the web can also be represented as: ASPX, if the logical layer is quite powerful and perfect, no matter how the presentation layer is defined and changed, the logic layer can provide services perfectly.
    • Specific methods of differentiation

      1: Data access layer: The main view of your data layer contains no logical processing, in fact, his various functions mainly to complete the operation of the data files. Without having to worry about other operations.

      2: Business Logic Layer: mainly responsible for the operation of the data layer. In other words, the operation of some data layers is combined.

      3: Presentation layer: The primary request is accepted by the user, and the data is returned, providing the client with access to the application.
    • Three-layer structure explanation

      The so-called three-tier architecture is the addition of a middle layer, also called the component layer , between the client and the database . Here the three-layer system, not refers to the physical three layer, not simply placed three machines is three-tier architecture, also not only B/s application is the three-tier architecture, three layer refers to the logic of the three layer, even if the three layers placed on a machine. The three-tier application puts business rules, data access, legitimacy checks, etc. into the middle tier for processing. Typically, the client does not interact directly with the database, but instead establishes a connection to the middle tier through com/dcom communication, which is then exchanged with the database through the middle tier.

      Developers can place the application's business logic on a middle-tier application server, separating the application's business logic from the user interface. In the premise of ensuring the client function, provide users with a concise interface. This means that if you need to modify your application code, you only need to make modifications to the middle-tier application server without modifying thousands of client applications. This enables developers to focus on the analysis, design, and development of the core business logic of the application system, simplifying the development, updating and upgrading of application systems.
    • So why apply the "intermediary business layer"? To cite some examples:
      We assume that there is a login code, you can handle the Web program, the façade layer is responsible for receiving the foreground page data, and then passed to the middle layer, the middle layer of data processing, such as formatting, anti-SQL injection and so on some, such data to the data access layer and then with the database operation, For example, with the database user name and password matching and so on some code.


    • There are many uses for the intermediary business layer, such as validating user input data, caching data read from the database, and so on ... However, theactual purpose of the "intermediary business layer" is to combine the most basic storage logic of the "Data Access layer" to form a business rule. For example: "There is a rule in a shopping site: The user who first purchases the site, the system automatically registers for it." Such business logic is best suited for the middle tier:

In the data access layer, it is best not to have any "business logic"! In other words, to ensure the "Data access layer" in the function of the atomic nature! That is, the minimum and no further points. The data access layer is responsible for storing or reading the data.

 
    • Asp. Three-tier structure description in net

      The requirement for a complete three-tier structure is to modify the presentation layer without modifying the logical layer and modifying the logical layer without modifying the data layer. otherwise your application is not multi-layered structure, or is the structure of the Division and organization is not a problem it is difficult to say. Different applications have different understandings, which is just a concept problem.
    • Understanding the three-tier structure in ASP -why is it divided into three tiers?

      We use three layer structure is mainly to make the project structure clearer, division of labor is more clear, conducive to later maintenance and upgrade. It does not necessarily improve performance because the main program module can only wait when the subroutine module does not finish. This means that dividing the application hierarchy will result in some loss of execution speed. But from the perspective of Team development efficiency, you can feel a very different effect.


      It needs to be explained that the three layer structure is not. NET, nor is it specifically used in the database technology. It is a more pervasive architecture design concept.


This kind of architecture should pay attention to the relationship between tables in database design and try to satisfy the relationship between the main and the child. In the function of the user to have a certain limit, do not behave in the deletion of the child table must be cautious, so as not to cause the main table and the child table data logically appear in the main table of the foreign key in the child table does not have a corresponding value.

    • A comprehensive query method for a table is:
      The main table is queried first, and the DL corresponding to the main table is called. Each sub-table is queried according to the records of the primary table. After the main table is added from the query results of the table, a large query collection is formed.
      For table operations (add and revise):
      At this point, only the primary table is manipulated, and the operation method in the DL corresponding to the main table is called.
      The RL layer is a logical judgment layer, which is the logical judgment of the incoming data on the page. Above the RL layer is the UI

    • The combination of surface object and actual

    • We know that building a bridge requires bricks, it should be ready to build the bricks before the bridge, but in order to explain the order and consistency, simplicity. We first built the bridge, the process of building the need for bricks to reproduce, so that there will be no more "bridge does not need things." Note that in practice, the bricks should be prepared first.
      The U layer is actually the bridge, the C layer is the brick, the D layer is the raw material (stone, sand). This also explains why the U-layer is referenced, dependent on the D-layer (not the level of U-C,c to D), because the bridge requires only bricks, but also stone sand.
    • Disadvantages of the "three-storey structure"
    • After reading this article, some netizens have raised some questions to me, which reminds me that the article has not mentioned the shortcomings of "three-storey structure". The "three-storey structure" of the word seems to have been very popular, the reason, perhaps the application of this development model is more common. But the "three-storey structure" is not a "panacea" of the Hundred Test Lark, it also has shortcomings. Here's the downside of it ...

      a very obvious drawback of the "three-tier structure" development model is that it is not executing fast enough. Of course, this "execution speed" is relative to non-layered applications. from the time series diagram given in the paper, this shortcoming is also obviously exposed. TraceLWord1 and TraceLWord2 do not have layered, direct calls to the classes provided by ADO to get the data. However, TraceLWord6 has to go through multiple calls to get to the data. The main program module can only be in the waiting state when the subroutine module program is not returned. So in the execution speed, the message board version of the higher, the ranking is more back. the "three-tier structure" development model does not apply to systems that are too demanding for execution speed, such as online bookings, online stocks, etc. It is more adept at systems that are prone to change in business rules.

      "Three-storey structure" development model, the entry difficulty is high enough, difficult to understand and learn. This is for beginners to design the program of the people. software developed in this mode usually has a slightly more code. This often makes beginners drown in the vast code. It is understandable to be fearful of it and to be disgusted with it.

      In fact, no matter what kind of development mode or method, are both pros and cons. There will be no "million usage" to solve any problems. So the "three-storey structure" of the word eye will not be an exception! Whether to use this model for system development, to make comparisons, tradeoffs can be. Avoid abuse!

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