Understanding of the system architecture

Source: Internet
Author: User

Understanding of enterprise-class system architecture

When we first began to learn the architecture, the concept of layering, the hierarchical architecture is more classic three-tier architecture, then what is the three-tier architecture? It includes the presentation layer, the business layer, the data access layer, and for a novice, the three-tier architecture in the abstract sense is logically divided into three layers.

This is the most basic three-tier architecture model.

The presentation Layer acts as the interface rendering of the system and the role of the UI logic, that is to say, the UI (user interface) belongs to the presentation layer;

For an ASP. WebForm, people like to write the control logic for the UI (read, set, event, and so on) in the back-hidden code of the page and rely on the business logic layer. Of course, server controls support data binding capabilities that can be bound to a control through a data source. This saves code in the post-hide.

Therefore, we can divide the presentation layer into UI user interface and UI logic:

the responsibility of the UI user interface is only as a display of data input and output.

the responsibility of the UI logic is to be responsible for the data interaction between the business logic layer and the UI user interface, and to make the UI logic independent of UI technology as much as possible .

The UI user interface is implemented in many ways, including asp.net,winform,wpf,silverlight, mobile web, smart devices, and so on.

The two modes that are currently used most are the MVC pattern and MVP mode, which separates the UI page and UI logic from the presentation layer.

The MVC pattern, the Model-view-Controller pattern , triggers and executes an action through the view, invokes the controller, operates the business layer through the controller, and finally returns the model, showing in the view. The model here can be a domain model (DM), or it can be a data migration object (DTO).

The MVP mode, the model-view-display mode , is a bit like the MVC pattern, unlike the MVP in which the view and the model are completely detached, the view defines an interface, and the viewer controls the view by invoking the interface's methods. As a result, the view and model are loose, and the display also acts as a controller, and it does not rely on UI techniques .

Also introduce a mode PM (preentation model), it can be said to be a variant of the MVP, in PM, the view does not define the interface, where the model is simply a class representing the view state, the elements in the view are directly bound to the model properties. In WPF, for example, WPF has innate data-bidirectional binding mechanisms and event notification property mechanisms.

So it is especially suitable for wpf,sliverlight and so on.

Before starting the business layer, you have to say a premise, in a small project, directly let the performance layer call the business layer, enough to solve all the problems. However, when a project is large enough to use multiple forms of expression, such as using a variety of UI technologies, ASP.NET,WPF, mobile devices, and so on, it is necessary to consider adding a layer between your presentation layer and the business layer to decouple the presentation layer from the business layer, as the business layer serves as a platform for business middleware It is best not to be exposed to the presentation layer, which is the legendary service layer . The architecture diagram also evolves to:

The service layer does not actually perform any specific work, its function is to organize the various business objects, the service layer hides all the details of the business layer from the presentation layer, the server organizes the components in the business logic layer, and interacts with the presentation layer through the Data Migration object (DTO), resulting in a DTO model.

In order to realize the reusability of the service , the service interface is used , and the performance layer accesses the function through the specified interface. The implementation of the service inherits the service interface, and the implementation of the service focuses on the invocation of the business layer .

For service tiers, common methods include Web services,. NET Remoting, rest, and WCF technologies.

I prefer to use WCF as a service, because it is easy to configure the purpose of remote invocation of the service through configuration.

The service layer eliminates the coupling between the two presentation layers and the business layer, and the service layer can implement a remote interface that achieves multi-UI technology and even multi-platform communication.

Of course, there are drawbacks to increasing the service layer, which, if you use WCF services, increases the system's call overhead, which in turn affects performance.

The business layer contains the implementation of the business process required by the system and interacts with the underlying data access layer.

We are often called the business layer called the business logic layer, but I think the business logic layer is one aspect of the business layer , and the business logic is more focused on the implementation of the logic algorithm in the business. Because the business layer can also include other aspects.

The business layer must include an object model that is modeled on the business entity, and the business rules that express all of the customer's policies and requirements, thus creating a domain Model .

(PS: If you do not use the domain model here, then you need to use the business rules layer to conduct business rules validation and control of the business functions)

Domain models include attribute definitions for entities, method definitions, and relationships between entities and entities. From this point of view, UML modeling is very important, through the UML dynamic diagram and static diagram description, can be mapped to the domain model.

The DTO mapping Layer (Dtomapper) is generated from the service layer just mentioned in the DTOs model, where a mechanism is needed to transform the DTO into a domain model.

In addition, the business layer includes core middleware technologies, including third-party components, workflow engines, and so on.

The business layer needs to take into account some design patterns that interact with the data access layer, including the object script pattern, the table module pattern, the activity record pattern, and the domain model pattern.

The thing scripting pattern is the process of executing a business process, which is a procedural model, and each method of a thing script has a specific thing script that focuses on the sequential operation of a sequence of processes on a business, it is simple to implement, but it has a fatal disadvantage that it causes a lot of duplicated code.

The table module mode has a certain structure compared to the thing script mode, its thought is also very simple, each data table defines a business component (entity class, Entity Operation Class), and more data interaction in. NET using DataSet as the table model. But it also has a drawback that it is driven from the database it is not suitable for a large number of data tables and the complex relationship between data tables.

In an object in active record mode , you can include data and methods. It is close to the structure of the data table, and its object execution methods can include CRUD operations, validation algorithms, and other computational functions. In general, the domain model is not too complex, and the activity logging pattern is a good choice. Of course he has problems, too, it is expensive to maintain for complex business, and if changes in requirements result in database modifications, the related code in the Record object model needs to be adjusted.

Classic applications: Linq-to-sql and Castle ActiveRecord.

domain model is derived from domain-driven design, which is a business-centric design pattern. It is quite suitable for complex business logic. The first three ways to use data-driven, data-driven approach features simple, but when the system to a certain scale, it will be difficult to maintain the degree.

The purpose of the data Access layer is clear, primarily as a function of providing data persistence, including reading and writing data, and also including transaction processing, concurrency control, and so on.

There are two ways to manipulate a database, such as ORM, ADO. NET mode.

ORM can be implemented using some third-party ORM frameworks, ADO. NET is implemented with the database operation of ASP.

Different databases have different persistence implementations, so add a storage-warehouse interface layer to accommodate different database implementations, where you can use the IOC-dependent injection method for database sizing, using unity, spring.net, Castle's IOC container and so on.

At the end of each tier, you can rely on the public infrastructure layer .

The public infrastructure layer can include common generic modules, logging log modules, exception anomaly modules, configuration modules, Di-dependent injection modules, unit test modules, and third-party components such as NHibernate , sprint.net, Castle, quartz scheduled tasks, etc.)

Final Picture:

Summary: Project type, project size and business requirements all affect the design of the system architecture, the system architecture is not a layer of change, there is no best architecture, only a better architecture, and from the project to think more about the scalability of the system. The analysis of architecture in this paper is only considered from the usual point of view, and in the project, you need to make adjustments according to the actual situation.


Understanding of the system 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.