Three modes Domain Driven Design (DDD) layered architecture

Mode 1: four-tier structure

1.User Interface is a user interface layer (or the presentation layer), is responsible for displaying information to the user and interpret user commands. Here the user can refer to another computer system, not necessarily the person using the user interface.
2.Application for the application layer, the definition of software to complete the task, and express concepts in the field of command objects to solve the problem. This layer is responsible for the work of great significance to the business, it is also necessary channels to interact with the application layer other systems. To the application layer as simple as possible, do not include business rules or knowledge, but only for areas subject coordination task in the next layer, distribution of work, so that they collaborate with each other. It does not reflect the state of the business situation, but it can have another state, show the progress of a task for the user or program.
3.Domain for the domain layer (or layers model), responsible for expressing business concepts, business rules and service status information. Although the details of the state of preservation business is performed by the infrastructure layer, but reflect the business conditions of this layer is controlled by the state and used. Field layer is the core business of software, domain model is located in this layer.
4.Infrastructure layer is a base layer embodiment, there is provided a common technical capabilities to other layers: an application layer message delivery, persistence mechanism for providing field layer, the user interface layer to draw the screen assembly, and the like. Infrastructure layer also capable of supporting interactive mode between the four levels by architectural framework.

Mode 2: five tiers

First, the three-tier architecture (Data, Context and Interactive)
the Data layer describes system and the relationships between concepts which areas of the layer and focus on the life cycle management of objects and relationships established in the field of these objects, the programmer stand systems thinking in terms of objects, so that "what the system is" easier to understand.
Context layers: one layer is as thin as possible. Context is often realized too stateless, just find the right role, so that role interaction together to complete the business logic can be. But simple does not mean unimportant, the display of the context layer is the man to understand the software business processes provide entry points and the main line.
Interactive layer is mainly reflected in the modeling role, and each role is a real performer in the context of complex business logic, of "What system do." role does is behavior modeling, which join the context and domain objects. Since the behavior of the system is complex and varied, so that the role of stabilizing the system and changing the field layer model system behavior layers were separated, the focus on the role of the system behavior modeling. This layer tends to focus on the scalability of the system, closer to the practice of software engineering, object-oriented design thinking in more perspective based on class.
Two, five tiers
1.User Interface is a user interface layer, primarily used for processing the request sent by the user Restful profile and parsing a user input or the like, and the information is passed to the interface of the Application layer.
2.Application layer is the application layer, responsible for multi-process management and scheduling, multi-thread management and scheduling, maintenance scheduling and multi-coroutine service instance state model. When receiving the request scheduling level user interface layer, layer entrusted Context context related to this service for processing.
3. the Context is environment layer, in the context of the unit, the art objects Domain cast layer into a suitable role, so that interactive role together to complete the business logic.
4.Domain layer is a layer of field, the domain model is defined to include not only the field of modeling the relationship between the object and further comprising explicit modeling of the role of the character object.
5.Infrastructure layer is a base layer embodiment, there is provided a common layer for other technical capabilities: service platform, programming framework, persistence mechanism, messaging, packaging, general algorithm third-party libraries, and the like.
Three, six architecture
1.User Interface is a user interface layer, primarily used for processing the request sent by the user Restful profile and parsing a user input or the like, and the information is passed to the interface layer Scheduler.
2.Scheduler scheduling layer is responsible for multi-process management and scheduling, multi-thread management and scheduling, maintenance scheduling and multi-coroutine service instance state model. When receiving the request scheduling level user interface layer, layer entrusted Transaction related to this operation is transaction processing.
3. the Transaction a transaction layer, corresponding to a business process, such as UE Attach, combining a plurality of synchronous message processing sequence into an asynchronous message or transaction, and in most scenarios, there selection structure. In case the transaction fails, then immediately rolled back. When the transaction layer receives a request dispatch layer, layer Action delegate Context treated, use is often accompanied layer Context Specification (predicate) selection of Action.
4.Context environmental layer to Action units processing a synchronous message or an asynchronous message, the art objects Domain layer cast into a suitable role, so that interactive role together to complete the business logic. Environmental Specification implemented also typically includes layers, i.e., to complete a condition judged by the Domain knowledge layer.
5.Domain layer is a layer of field, the domain model is defined to include not only the field of modeling the relationship between the object and further comprising explicit modeling of the role of the character object.
6.Infrastructure layer is a base layer embodiment, there is provided a common layer for other technical capabilities: service platform, programming framework, persistence mechanism, messaging, packaging, general algorithm third-party libraries, and the like.

Mode III: hexagonal architecture

One way to improve the layered architecture, i.e. Dependency Inversion Principle (Dependency Inversion Principle, DIP), which achieve the purposes of the improvements by changing the dependencies between the different layers.
According to this definition, DDD layered architecture of the low-level components should rely on an interface to provide high-level components, namely, whether high-level or low-level dependent on the abstract, the entire layered architecture seems to be pushed flat. If we put a layered architecture bulldozed, to which add some symmetry, there will be a kind of architectural style characteristic of symmetry, that hexagonal architecture. Alistair Cockburn hexagonal architecture is proposed in 2005, in this architecture, different customers by way of "equality" interact with the system. New customers need it? not a problem. Just add a new client adapter input parameters that can be converted into a system of API understood on the line. Meanwhile, for each particular output, there is a new adapter is responsible for completing the conversion function.

Hexagonal architecture also known as port adapter, as shown below:
Here Insert Picture Description

Different sides of each hexagon represent different types of ports, the input ports or the processing, or output processing. For each type the outside, there is a corresponding adapter, external application layer API to interact with the interior. Figure above three customer requests are arriving same input port (the adapter A, B and C), another client requests to use an adapter D. Suppose first three requests the HTTP protocol (browser, REST, and SOAP, etc.), followed by a request using AMQP protocol (such as RabbitMQ). Port and there is no clear definition, it is a very flexible concept. Either way port to be divided, when a client request arrives, there should be a corresponding adapter input transformation, then the port will invoke an operation of the application or send an event to the application, thus control over pay to the inner region.
The client application receives a request through a common API, to handle the request using the domain model. We can achieve the modeling elements DDD tactics designed Repository (repository) is seen as a persistent adapter, the adapter is used to access previously stored instance of polymerization or save the new aggregation instance. As shown in the adapter E, F and G shows, we can achieve in different ways repositories, such as relational databases, file-based storage, and distributed cache or memory storage. If an application sends a message to the outside world field events, we will use the adapter H for processing. The message output processing adapter, and the adapter AMQP message processing is the above-mentioned process incoming messages, thus should use a different port.
We in the actual project development, the components of the different layers can be developed simultaneously. When the function of a specific component, you can start development immediately. Since a plurality of users of the assembly, and a different focus of these users, it is necessary to provide a plurality of different interfaces. At the same time, these users also deepening understanding, may fire several times reconstructed the relevant interface. Thus, the components of multiple users often find developers assembly to discuss these issues, potentially reducing the efficiency of the development component.
We put it another way, the developer components in the clear after the functional components focused on the development function to ensure stable and efficient function. User Interface component own custom components (port), and then write a test based on the interface, and evolving interface. When cross-layer integration testing, the component developer or a user redevelopment adapter on it.

Guess you like

Origin www.cnblogs.com/zhaoshujie/p/12216494.html