The three-tier architecture of the software

Source: Internet
Author: User

I don't understand it at all.

Research report based on software three-tier architecture

Introduction

The three-layer structure is the development of the traditional customer/server structure, which represents the future of enterprise application, and the typical Web application. The meaning of the multilayer structure and the three-layer structure is the same, only the details are different. There are two tiers, three layers of these formulations, is due to the application to solve three levels of problems.

I. Software architecture and tiering

(i) Software architecture (software architecture)

is a series of related abstract patterns used to guide the design of large software systems in all aspects. Software architecture is a sketch of a system. The object of software architecture description is the abstract component that directly forms the system. The connection between the components clearly and relatively carefully describes the communication between the components. In the implementation phase, these abstract components are subdivided into actual components, such as detailing a class or object. In the object-oriented domain, connections between components are often implemented using interfaces (computer science). Software architecture is the foundation of building computer software practice. With architects setting design principles and objectives for building projects, as a basis for graphing drawings, a software architect or system architect presents the software architecture as the basis for a practical system design that meets the needs of different customers.

(ii) Stratification

Hierarchies are groupings of functions that are organized in an orderly manner: application-specific features are located on the upper level, functions that span the application domain are located in the middle, and configuration environments are located on the lower level. Stratification logically divides subsystems into many sets, and the formation of inter-layer relationships follows certain rules. By layering, it is possible to limit the dependencies between subsystems, making the system more loosely coupled and thus easier to maintain. The grouping criteria for subsystems includes the following rule visibility. Each subsystem can only be dependent on the subsystems of the same layer and its next layer.

(iii) the need to use tiered architecture development

1, layered design agreed to your cutting function into different areas. In other words, a layer is designed to be a grouping of logical components. For example, a layer can access the B-layer, but B-layer can not visit a layer.

2. Use a layered approach to improve serviceability of the application and make it easier to scale to improve performance.

(iv) Principles of design layering

1, layer means the logical grouping of the formation. For example, a different layer should be used for the user interface, business logic, and data access organization.

2, in a layer within the formation should be aggregated. A business layer build should provide only the operations that are related to the business logic, rather than providing other operations.

3, in the design of each layer interface to consider good physical boundaries. Assume that the communication expands the physical boundary, using message-based operations, otherwise using object-based operations.

4, consider using the interface type (interface) to define the interface for each layer. This will allow you to create different implementations of the interface to improve the scalability.

5. For Web applications, it is a good idea to implement a message-based interface between the presentation layer and the business logic layer, even if the two layers do not cross physical boundaries. Message-based interfaces are more appropriate for stateless web operations.

Ii. three-tier architecture of the software

(i) 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 layers, from bottom to top: Data access layer, business logic layer (also called domain layer), presentation layer.

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.

2, the Business Logic layer (BLL): For the detailed problem of operation, but also can be said to the data layer operation, the data business logic processing.

3, data access Layer (DAL): This layer of transactions directly manipulate the database, for data additions, deletions, changes, lookups and so on.

  

(ii) Three-storey 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-layer architecture, also not only B/s application is the three-tier architecture, three layer refers to the logical three layer, even if the three layers placed on a machine. The three-tier application puts business rules, data access, and legitimacy checks 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.

(iii) The role of each layer

Data Access Layer:

Sometimes referred to as the persistence layer, its function is primarily to provide access to the database, to the database system, to binary files, to text documents, or to XML documents. The simple argument is to implement the select,insert,update,delete of the data table. Assuming that you want to add an ORM element, it contains the mapping between the object and the data table, as well as the persistence of the object entity. The main is 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, detailed for the business logic layer or presentation layer to provide data services.

Business Logic Layer:

Mainly for the operation of the detailed problem, but also to understand the operation of the data layer, the data business logic processing, assuming that the data layer is a building block, the logic layer is the building of these blocks. 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 (domain) of the system's logic, very often, also the business logic layer called the domain layer. Martin Fowler, for example, Patternsof Enterprise application Architecture, divides the entire architecture into three basic layers: the presentation layer, the domain layer, and the data source layer.   As the pioneer of domain-driven design, Eric Evans has made a more careful division of the business Logic layer, which is subdivided into application and domain layers, further separating the domain logic from the solution of domain logic through layering. The location of the business logic layer in the architecture is critical, and it is in the middle of the data Access layer and 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. Assuming that the concept of interface-oriented design is adhered to in layered design, such a 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. Dependencies 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.

Presentation layer:

On the outermost (topmost), near the user. Used to display data and receive user input data, to provide users with an interactive interface. The main means of the web, but also can be expressed as a WinForm way, the web can also be represented as: ASPX, assuming that the logical layer is quite powerful and intact, no matter how the presentation layer is defined and changed, the logical layer can provide the service in good condition.

(d) Detailed call

Microsoft's DNA architecture defines three layers: the presentation layer (presentation), the business logic layer, and the data access layer. Detailed also divides into: interface appearance layer, interface rule layer, business interface layer, business logic Layer, entity layer, data access layer, data storage layer total seven layers, its detailed call 1 sees:

(v) Rules


1. There is no cross-layer call between the hierarchy of the system and the sub-level within the layer.
2. Entityobject data is passed between tiers.
3. Data that needs to be bound to a list at the UI layer is passed with a relational-based dataset, and in addition, the data should be passed using Entityobject.
4. For each database table (table) there is a DB Entity class corresponding to it, and for each entityclass there will be a BEM class corresponding to it.
5. Some cross-database or cross-table operations, such as complex federated queries, also need to be supported by a corresponding BEM class.
6. For relatively simple systems, it is possible to consider merging the business function sub-layer into one.
7. The UI layer and the BL layer prohibit any SQL statements from appearing.

Iii. Advantages and Disadvantages

(a) Strengths

1, the developer can only focus on one layer of the whole structure;

2, can very easy to use the new implementation to replace the original level of implementation;

3, can reduce the layer and layer of dependence;

4, in favor of standardization;

5, facilitate the reuse of the logic of each layer.

(ii) shortcomings

1, reduce the performance of the system. This is self-evident. Assuming that a hierarchical structure is not adopted, a very many business can directly access the database to obtain the corresponding data, now it must be completed through the middle tier.

2, sometimes cause cascade changes. Such changes are especially true in the top-down direction today. Suppose you need to add a function in the presentation layer, in order to ensure that the design conforms to the layered structure, you may need to add the corresponding code in the corresponding business logic layer and data access layer.

3. Added development cost.

(c) Why a three-tier architecture is used

For a simple application, where the amount of code is not very large, a layer of structure or two-layer structure development is fully sufficient, there is no need to complicate it, assuming that a complex large-scale system, designed for a layer of structure or two-layer structure development, then this design is very serious flaws. The following is a detailed description of the fact that tiered development serves large systems. In the development process, 0 of the basic program personnel have similar functions often copied code, then the same code written so many times, not only to make the program lengthy, but also not conducive to maintenance, a small change may involve a very many pages, often resulting in abnormal production of the program is not normal execution. The most basic object-oriented thought did not get the slightest embodiment, the object-oriented pretence is still walking the process-oriented road. Aware of this problem, 0 of the basic program staff began to write some common handlers in the program as public methods, encapsulated in a class, and called by other programs. For example, write a data operation class, the data operation reasonable encapsulation, in the database operation process, only the corresponding method in the class (data addition, change, query, etc.) can complete the specific data operation, this is the data access layer, do not have to write those repeated database operation code each time the database operation. In the new application development, the data access layer can be used directly. One of the three main features of object-oriented encapsulation is here to be very well represented. Now found the object-oriented sense, the code volume has been greatly reduced, and changes in the time is also more convenient, but also to achieve the reuse of code.

iv. differences from MVC

   MVCis the abbreviation for three words, respectively:Model(Model),View(View)and ControlController). MVCThe purpose of the pattern is to achieveWebthe functional division of the system. Modellayer to implement the business logic in the system, usually withJavaBeanorEJBto achieve. Viewlayers are used to interact with users, often usingJSPto achieve. Controllerlayer isModelwith theViewBridge between communication, it is able to assign users ' requests and select the appropriate view for display, at the same time it is also able to interpret the user's input and map them to operations that the model layer can run.

The same is the architecture level, the same thing is that they all have a presentation layer, but their different place is the other two layers.

The concept of a controller is not defined in the three-tier architecture. Nor does MVC consider the business's logical access to two layers, which is the basic difference between a three-tier architecture or an MVC build program. Of course, the model is also mentioned in layer three, but the concept of model in the three-tier architecture is not the same as the concept of model in MVC, and the typical model layer in the "three layer" is made up of entity classes, while MVC is composed of business logic and access data.

V. Summary

In the design of software architecture, layered structure is the most common and most important structure. Therefore, layered design can be used for the following purposes: Decentralized attention, loose coupling, logical multiplexing, and standard definitions. A good layered structure can make the developer's Division of labor more clear. Once the interfaces between the various levels are defined, developers responsible for different logic designs can distract and go hand in hand. Although the three-tier architecture still has an unavoidable flaw, the software hierarchy makes code maintenance easy, and the design understands that each layer is independent and focused on the areas that it specializes in. This report provides a deeper understanding of the architecture of the software.


The three-tier architecture of the software

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.