Three-tier Architecture: Presentation layer (i.e. interface layer UI)--data access layer (business logic level)--(Database access level)
Since the layer is a weakly coupled structure, the dependencies between layers and layers are downward, and the bottom layer is "ignorant" to the upper layer, and changing the upper-level design has no effect on the bottom of its invocation. If you follow the idea of interface-oriented design in a layered design, this downward dependency should also be a weak dependency. Therefore, without changing the definition of the interface, the ideal layered architecture should be a "drawer" architecture which can be extracted and replaceable. Because of this, the design of the business logic layer is especially critical for a scalable architecture, because it plays two different roles. For the data access layer, it is the caller and, for the presentation layer, it is the callee. Dependency and dependent relationships are entangled in the business logic layer, and how to implement the decoupling of dependencies is a task left to the designer in addition to implementing business logic.
The three-tier architecture (3-tier application) typically has a three-tier architecture that divides the entire business application into: Presentation layer (UI), Business Logic Layer (BLL), data access Layer (DAL). The purpose of distinguishing hierarchy is to "high cohesion, low coupling" thought.
1, the presentation layer (UI): Popular speaking is to show the user interface, that is, the user in the use of a system when he saw the gains. (for presentation only)
2, Business Logic Layer (BLL): The operation of the specific problem, it can be said that the operation of the data layer, the data business logic processing. (The key is to abstract logical data from raw data ) to provide all the functionality at the INTERFACE\API level. , 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 .
3, data access Layer (DAL): This layer of transactions directly manipulate the database, for data additions, deletions, modifications, lookups and so on. (The key is the granularity of the grasp ) to ensure that 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.
Overview
In the design of software architecture, layered structure is the most common and most important structure. Microsoft's recommended layered structure is generally divided into three tiers, from bottom to top: The data access layer, the business logic layer (or also called the domain layer), the presentation layer.
Three-layer structure principle:
In 3 levels, the main functions and business logic of the system are processed in the business logic layer.
The so-called three-tier architecture is the addition of a "middle tier", also called a 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 with the middle tier through com/dcom communication, and then interacts with the database through the middle tier.
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.
Presentation Layer
At the outermost (topmost), closest to the user. Used to display data and receive user input data, to provide users with an interactive interface.
Business Logic Layer
The business logic layer is undoubtedly the part of the system architecture that embodies the core value. Its focus is mainly on the development of business rules, the implementation of business processes and other business requirements related to the system design, that is, it is related to the domain of the system (domain) logic, and many times, the business logic layer is also called the domain layer. For example, Martin Fowler, in the book Patterns of Enterprise application Architecture, divides the entire architecture into three main layers: the presentation layer, the domain layer, and the data source layer. As a pioneer in domain-driven design, Eric Evans has made a more detailed division of the business Logic layer, subdivided into application and domain layers, and further separates domain logic from domain logic solutions through layering.
The position of the business logic layer in the architecture is critical, it is in the middle of the data access layer and the presentation layer, which plays the role of connecting link in the data exchange. Since the layer is a weakly coupled structure, the dependencies between layers and layers are downward, and the bottom layer is "ignorant" to the upper layer, and changing the upper-level design has no effect on the bottom of its invocation. If you follow the idea of interface-oriented design in a layered design, this downward dependency should also be a weak dependency. Therefore, without changing the definition of the interface, the ideal layered architecture should be a "drawer" architecture which can be extracted and replaceable. Because of this, the design of the business logic layer is especially critical for a scalable architecture, because it plays two different roles. For the data access layer, it is the caller and, for the presentation layer, it is the callee. Dependency and dependent relationships are entangled in the business logic layer, and how to implement the decoupling of dependencies is a task left to the designer in addition to implementing business logic.
Data layer
Data Access layer: sometimes referred to as the persistence layer, its function is mainly responsible for database access, access to the database system, binary files, text documents or XML documents.
The simple argument is to implement the select,insert,update,delete of the data table. If you want to add an ORM element, it will include the mapping between the object and the data table, and the persistence of the object entity.
Advantages and Disadvantages
1, the developer can only focus on the entire structure of one of the layers;
2, can easily use the new implementation to replace the original level of implementation;
3. Can reduce the dependence between layer and layer;
4, in favor of standardization;
5, facilitate the reuse of the logic of each layer.
Disadvantages
1, reduce the performance of the system. This is self-evident. Without a tiered structure, many businesses can access the database directly to get the data, and now they have to do it through the middle tier.
2. Sometimes cascade changes are caused. This kind of modification is especially reflected in the top-down direction. If you need to add a feature in the presentation layer to ensure that the design conforms to the layered structure, you may need to add code to the appropriate business logic layer and the data access layer.
3, increase the development cost.
Rules
Three-layer structure of the program is not to say that the project into the Dal, BLL, WebUI three modules called three layers, the following questions in your project:
1. There are only a few (or no) SQL statements or stored procedure calls inside the Uilayer, and these statements guarantee that the data will not be modified?
2. If Uilayer is removed, will your project provide all the functions on the INTERFACE/API level?
3. Can your DAL be ported to other projects of similar environment?
4. Three modules can be run on different servers separately?
If not all of the answers are yes, then your project is not a strictly three-tier program. The three-tier program has some rules that need to be agreed upon:
1. Most critical, the UI layer can only be used as a shell and cannot contain any bizlogic processes
2. Design should start from the BLL, not the UI. The BLL layer should implement all bizlogic on the API, in an object-oriented manner
3. Regardless of whether the data layer is a simple sqlhelper, or with mapping classes, should be in a certain degree of abstraction to achieve system-independent
4. Regardless of whether the use of COM + (Enterprise Service), or remoting, or webservice and other remote object technology, regardless of deployment time is not really deployed to different servers, at least in the design time to do such considerations, further, You also need to consider multiple servers that are clustered by load balancing
So consider whether a project should be applied to the three-layer/multilayer design, first to consider whether it is really necessary? In fact, most programs open a webapplication is enough, there is absolutely no need to do so complex. Multi-layered structures are designed to address the needs of truly complex projects.
Http://wenku.baidu.com/view/4b290a6cb84ae45c3b358c47.html?re=view
C # three-tier architecture