Abstract: As the digital world continues to evolve, software architecture design ideas are constantly optimized in collision. The arrival of the cloud native era has accelerated the industry’s demand for domain-driven Design.
This article is shared from huawei cloud community “Cloud Native Era, Domain Driven Design ideas (DDD) How to Land? , author: A quick wit.
As the digital world continues to evolve, software architecture design ideas are constantly optimized in collision. The arrival of the cloud native era has accelerated the industry’s demand for domain-driven Design.
At the just concluded DDDChina2021 Domain-Driven Design Summit, Huawei Cloud data Modeling architect Ling Yun shared her understanding and practice of domain-driven design concepts.
Evolution of software architecture
In recent years, with the rapid development of economy and science and technology, software systems have more or less been applied in all walks of life. The rapid development of e-commerce, banking and other industries has brought about the improvement of business complexity and access concurrency, which have put forward higher requirements for the reliability and stability of software. Therefore, in recent years, software architecture has experienced the evolution process from single architecture, to distributed architecture, to the current mainstream microservice architecture, and the gradually emerging Serverless architecture.
What is Domain-Driven Design Thinking (DDD)?
The full name of DDD is domain-driven Design, that is, domain-driven Design. It is a process of finding problems, abstracting common processes and providing solutions to problems in a certain Domain. Its method is to reduce the complexity through a series of means such as unified language domain modeling and domain division, and hierarchical planning based on OOP technology, to unify the language used in the whole life cycle of software development, and emphasize a process of combining business and technology.
– Why model?
Modeling allows business people and technical people to communicate with each other through visual models. At the same time, after we make a model, we can easily reuse and spread it, modify it in other projects, and finally document the decisions we make.
– What is the domain model?
The logic of the domain is explicit expertise. For example, if you need to develop a software system for legal personnel, there will be problems like this: Legal personnel do not understand software development, and developers do not understand legal information, and in the development process they need to carry out continuous communication and confirmation, the legal field model is a bridge to connect the two, domain model mainly tends to describe the domain knowledge to manage compliance.
– Relationship between domain modeling and software architecture
How does DDD land
Below through a specific data modeling software case to explain how to land DDD.
Taking the development of a data modeling software as an example, the logical model and physical model are shown as follows:
The logical model
The physical model
We can implement DDD landing through the following steps:
1. Communicate with experts in the field
Communication with domain experts is the most important part of the process, in which business modelers need to be familiar with concepts, operations, behaviors, constraints, etc. Therefore, the first step in domain modeling is to define business boundaries and shrink all behaviors of the system to the visual modeling domain. Secondly, it is necessary to understand the logic of data change. In the process of concept-logic-physics forward design of visual modeling, concept drives logic, logic drives physics, and users of different roles pay different attention to different stages. From a business perspective, entity changes drive table changes; From the user’s perspective, business logic changes require system adaptation. Finally, the requirements are verified with domain experts and the logic is pushed forward: if the entity change audit is passed, the corresponding table will be driven to change. This change in the physical model, the developer should modify the implementation of the software system according to the changes in the table.
2. Implement the corresponding domain model
Reasonably plan the relationship and inheritance of business objects, entities containing attributes, tables containing fields, tables containing indexes, relations associated with two entities, ER graphs containing entities, relations, etc. Determine the aggregation relationship, entity header information and attribute list constitute entity, table header information and field list + index list constitute table, version status and process constitute versioning. Next, we need to determine value objects, such as field type, index type, operation action type, etc. Finally, we need to verify the requirements of domain model. Through the above process, we realize a domain model, as shown in the figure below:
According to the established domain model, the general part is abstracted out, the corresponding UML diagram is also modified, and the domain model has been created.
3. Design prototype interface and interaction logic
Implement a corresponding domain model, and then design the prototype interface and interaction logic, which can be understood as various events and event drivers of this domain model.
4. Domain model automatically generates structural framework code
UML diagrams built from the domain model can directly generate project framework code, in which corresponding entity classes are generated, and corresponding event codes are generated for various events.
UML diagrams automatically generate framework code
5. Refine and optimize in the framework
The code framework can be used directly. If other content needs to be extended, such as the function of querying historical versions in addition to adding, deleting and modifying, such events are difficult to be expressed on the domain map, or the generated events may not be accurate after being expressed, so the code in this case needs to be written by software developers. But you don’t need to focus on the framework of the interface or the service layer, you just need to add capabilities where they are.
The modeling software system landing completed through the above steps can not only automatically generate code but also do a good job of monitoring, so as to maintain the consistency of the architecture and DDD model.
Do you have a basic understanding of domain-driven design (DDD)? The application of any concept requires in-depth experience and repeated practice. I hope this article can give you some inspiration and help.
Click to follow, the first time to learn about Huawei cloud fresh technology ~