Description of ASP. NET three-tier architecture and disadvantages of three-tier architecture

Source: Internet
Author: User

ASP. NET three-layer structure description

The perfect three-tier structure requires that you modify the presentation layer instead of the logic layer, instead of the data layer. Otherwise, it is hard to say whether your application has a multi-layer structure, or whether there is a problem with the Division and organization of the layer structure. Different applications have different understandings. This is just a conceptual question.

Understanding ASP. NET's three-tier structure-why is it divided into three layers?

We use a three-tier structure to make the project structure clearer and the division of labor clearer, which is conducive to 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 an application into layers will cause some loss in its execution speed. However, from the perspective of team development efficiency, we can feel a big difference.

It should be noted that the layer-3 structure is neither a. NET patent nor a technology dedicated to databases. It is a more universal architecture design concept.

In this architecture, we need to pay attention to the relationship between tables in the database design, and try our best to satisfy the relationship between the master and the child. Users must have certain functional limitations. do not exercise caution when deleting sub-tables, in this case, the foreign keys of the primary table that are logically present in the data of the primary table and the sub-table do not have the corresponding values in the sub-table.

The following table query methods are used:

First, query the master table and call the DL corresponding to the master table. Query each sub-table based on the records of the master table. A large query set is formed after the query result of the Self-table is added to the master table.

Add, delete, and modify operations on tables ):

In this case, only the primary table is operated and the operation method in the DL corresponding to the primary table is called.

The RL layer is the logical judgment layer, mainly used to perform logical judgment on the data uploaded to the page. Above the RL layer is the UI

How to build a three-tier architecture solution

Create a blank solution. Then:

"Add"-"New Project"-"Other Projects"-"Enterprise template project"-"C # generate blocks"-"Data Access" data layer, referred to as "D Layer)

"Add"-"New Project"-"Other Projects"-"Enterprise template project"-"C # generate blocks"-"Business Rules" business layer, hereinafter referred to as "C layer)

"Add"-"New Project"-"Other Projects"-"Enterprise template project"-"C # generate blocks"-"Web User Interface" layer, hereinafter referred to as the U layer)

Right-click solution> Project dependency, and set U to depend on D, C, and D.

Add references D and C to U, and add references D to C.

So far, a three-tier shelf has been established. What I said above is very specific and "stupid". People who know me think I am nonsense. In fact, during this time, I strongly felt that many people actually did not understand this simple process. Although there is no objection to creating two "Empty Projects" and one "Asp net Web Application Project", it can also be used as a three-layer framework, many people think that these "enterprise-level template Projects" are actually empty projects, which is a misunderstanding. Yes, you can see from the solution resource manager that there is nothing in the enterprise-level template project. But you can open the project file in notepad and see the difference ?? You can't see some things behind the scenes, but the system is ready. That is to say, if you "using System Data SqlClineit" in a class in the C layer or use a SqlConnection object, no errors will occur during compilation, however, some "policy warnings" will be generated in the "task list" to warn you not to put things that should be placed on layer D in layer C, although it is true for the program, but the readability and maintainability are discounted.) This function cannot be provided to empty projects.

In the new TraceLWord3, the "enterprise-level template project" is applied ". Place the original LWordTask. cs in a single project named AccessTask. In the solution, a new project named InterService is created, which contains an LWordService. cs program file, which is the "intermediate business layer" program. To avoid repeated names, the TraceLWord3 website is placed in the WebUI project. For more complete code, you can find it in the CodePackage/TraceLWord3 directory --

ASP. NET three-layer structure: Combination of face object and reality

We know that building a bridge requires bricks. We should first prepare bricks and then build the bridge. However, in order to explain the sequence and consistency, it is simple. We should first build a bridge and reproduce the bricks during the construction process, so that there will be no more "things not needed by the bridge ". In practice, you should prepare bricks first.

The U layer is actually a bridge, the C layer is a brick, and the D layer is a raw material stone, sand ). This also explains why the U layer references and depends on the D Layer instead of the U to C and C to D layers), because the bridge requires both bricks and sand.

Disadvantages of "three-tier structure"

Some netizens raised some questions after reading this article, reminding me that the article has not mentioned the disadvantages of "three-layer structure. The word "three-layer structure" seems to have been popular all the time. The reason may be that this development mode is widely used. However, the "three-layer structure" is not a hundred trials of the "Wan Ling medicine", it also has shortcomings. Let's talk about its shortcomings ......

One obvious disadvantage of the "three-tier structure" development model is that it does not run fast enough. Of course, this "execution speed" is relative to non-hierarchical applications. According to the sequence diagram given in sequence, this disadvantage is also obviously exposed. TraceLWord1 and TraceLWord2 are not layered, And the classes provided by ADO. NET are called directly to obtain data. However, TraceLWord6 does need to be called multiple times to obtain data. When the subroutine Module Program does not return, the main program module can only be in the waiting state. Therefore, the higher the message board version, the lower the ranking. The "three-tier structure" development model is not applicable to systems that require too much execution speed, such as online ticket booking, online stock trading, and so on ...... It is better at systems where business rules are easy to change.

The "three-tier structure" development mode is difficult to get started and difficult to understand and learn. This is intended for beginners. The amount of code for software developed in this mode is usually slightly higher. This will often overwhelm beginners in the vast amount of code. It is understandable that you are afraid of it ......

In fact, no matter which development mode or method it is, there are advantages and disadvantages. There is no "Universal Method" to solve any problem. Therefore, the word "three-layer structure" is not an exception! Whether to use this mode for system development requires comparison and trade-offs. Do not abuse it!

  1. ASP. NET Overview
  2. Analysis of ASP. net ajax Components
  3. Installation and simple configuration of ASP. NET AJAX
  4. Analysis on the AutoComplete control of Asp.net Ajax Control
  5. Analysis on installing ASP. NET on Windows Server 2003

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.