02 | Domains, subdomains, core domains, general domains and support domains: stupidly confused?

Table of contents

How to understand domains and subdomains?

How to understand the core domain, general domain and support domain?

Then why divide the core domain, general domain and support domain, and what is the main purpose?

Summarize


The DDD knowledge system proposes many nouns, such as: domain, subdomain, core domain, general domain, support domain, bounded context, aggregation, aggregate root, entity, value object, etc., there are many. These nouns are all key concepts, but they are really a bit obscure, which may cause everyone to retreat before they start practicing DDD.

This article focuses on important concepts such as DDD's domain, subdomain, core domain, general domain, and support domain.

How to understand domains and subdomains?

Let’s first look at the definition of domain in the Chinese dictionary: “A domain is a scope, department or department engaged in a specialized activity or business.” Baidu Encyclopedia’s explanation of a domain: “A domain specifically refers to a specific range or area. "

Both interpretations have one thing in common - scope. correct! The domain is used to determine the scope, and the scope is the boundary, which is why DDD constantly emphasizes the boundary in the design.

When researching and solving business problems, DDD will subdivide the business domain according to certain rules. When the domain is subdivided to a certain extent, DDD will limit the scope of the problem to a specific boundary, and establish a domain model within this boundary , and then implement the domain model with code to solve the corresponding business problems. In short, the domain of DDD is the domain of business problems to be solved within this boundary.

Since the field is used to define the business boundary and scope, there will be a difference in size. The larger the field, the larger the business scope, and vice versa.

Domains can be further divided into sub-domains. We call the divided subfields subfields, and each subfield corresponds to a smaller problem domain or smaller business scope.

We know that DDD is a design idea that deals with highly complex domains, and it tries to separate the complexity of technical implementation. So in the face of intricate business fields, how does DDD make the business from complex to simple, easier for people to understand, and easier for technology implementation?

In fact, it is easy to understand that the research method of DDD is similar to that of natural science. When people encounter complex problems in natural science research, the usual practice is to subdivide the problem step by step, and then conduct in-depth research, explore and establish the knowledge system of all sub-domains for the subdivided problem domains one by one. When all problem sub-domains are studied, we have established a complete body of knowledge for all domains.

Let's take a look at the picture above. This example is about how to build a complete biological knowledge system for peach trees. In fact, the junior high school biology class has already told us the research method. Its research process is like this.

  • The first step: determine the research object, that is, the research field, here is a peach tree.
  • The second step: Subdivide the research object, subdivide the peach tree into organs, and the organs are divided into two kinds of vegetative organs and reproductive organs. The vegetative organs include roots, stems and leaves, and the reproductive organs include flowers, fruits and seeds. The knowledge system of peach trees is the problem domain that we have determined to study, corresponding to the domain of DDD. Organs such as roots, stems, leaves, flowers, fruits, and seeds are subdivided problem subdomains. This process is how DDD subdivides the domain into sub-domains.
  • Step 3: Subdivide the organ and subdivide the organ into tissues. For example, leaf organs can be subdivided into protective tissues, vegetative tissues, and conducting tissues. This process is the process by which DDD further subdivides the subdomain into multiple subdomains.
  • The fourth step: Subdivide the tissue, subdivide the tissue into cells, and the cells become the smallest unit of our research. The cell walls between cells define the boundaries of the cells and also the minimum boundaries of the study.

We know that the nucleus, mitochondria, cell membrane and other substances together constitute the cell, and these substances work together to allow the cell to have the specific biological functions of this type of cell. Here you can understand the cell as the aggregation of DDD, and these substances in the cell can be understood as the aggregate root, entity and value object in the aggregation, and these entities cooperate together to complete specific business functions in the aggregation. This process is similar to the process of determining the functional elements and boundaries within a microservice during DDD design.

To sum up here, it means that each subdivided field will have a knowledge system, which is the domain model of DDD. After the research of all sub-domains is completed, we have established the knowledge system of the whole domain, and also established the domain model of the whole domain.

Above we used the method of natural science research to illustrate that the field can be subdivided into sub-fields to reduce the complexity of research. Now let's switch this topic to the business field, and compare and verify whether the subdivision process of the two is consistent.

Here is an example from my insurance industry. Insurance is a relatively large field. The insurance core system long ago implemented all functions in one system. This system is what we often call a single system. Later, the monolithic system began to be unable to adapt to the development of the insurance business, so the insurance company began the transformation of the middle office, introducing a distributed micro-service architecture to replace the original monolithic system. The distributed microservice architecture needs to divide the boundaries of the business domain, establish a domain model, and realize the implementation of microservices.

In order to realize the modeling of the insurance domain and the construction of microservices, we can subdivide the insurance domain into sub-domains such as underwriting, collection and payment, reinsurance, and claims settlement according to the degree of business relevance and process boundaries, and the underwriting sub-domain can be further subdivided into Insurance, preservation (life insurance), correction (property insurance) and other sub-subdomains.

In the bounded context of insurance, the domain model of insurance can be established, and the domain model of insurance is finally mapped to the system as the microservice of insurance. This is the subdivision of the insurance field and the construction process of microservices.

Then you might say, I am not from the insurance industry, how do I understand this process? In my opinion, the business models of different industries may be different, but the process and method of domain modeling and microservice construction are basically similar. The core idea is to gradually decompose the problem domain and reduce the complexity of business understanding and system implementation.

How to understand the core domain, general domain and support domain?

In the process of continuous domain division, the domain will be subdivided into different sub-domains, and the sub-domains can be divided into three types of sub-domains according to their own importance and functional attributes, which are: core domain, general domain and support domain.

The sub-domain that determines the product and the core competitiveness of the company is the core domain, which is the main factor for the success of the business and the core competitiveness of the company. There is not much personal appeal, and a general function subdomain used by multiple subdomains at the same time is a general domain. There is also a functional subdomain that is required, but does not contain the functions that determine the product and the company's core competitiveness, nor the subdomain that contains general functions, which is the supporting domain.

Compared with these three types of sub-domains, the core domain is the most important. When we talk about the purpose below, we will use the core domain as an example to introduce it in detail. If the general domain and support domain correspond to the enterprise system, for example, the general domain is the general system you need to use, such as authentication, permissions, etc., such applications are easy to buy, and there are no restrictions on enterprise characteristics. Do too much customization. The supporting domain has enterprise characteristics, but it is not universal, such as systems such as data codes and data dictionaries.

Then why divide the core domain, general domain and support domain, and what is the main purpose?

Let’s take the peach tree in the picture above as an example. We subdivide the peach tree into six sub-domains including root, stem, leaf, flower, fruit and seed. Does the peach tree have a core domain? If so, which one is the core domain?

Different people have different understandings of peach trees. If this peach tree grows in a park, in the eyes of the gardener, what he likes is March in Yangchun when "the peach blossoms on the human face reflect the red", when the flowers are the core area of ​​the peach tree. But if this peach tree grows in an orchard, for the fruit farmer, he hopes to harvest fruitful peaches in the harvest season, when the fruit is the core area of ​​the peach tree.

In different scenarios, different people have different understandings of the core domain of peach trees, so the processing methods of peach trees will also be different. Gardeners pay more attention to the nutrition of peach trees during the flowering period, while fruit growers pay more attention to the nutrition of peach trees during the fruit drop period. Sometimes, in order to ensure the nutritional supply of fruits, they will cut off the overgrown stems and leaves (general domain or support domain).

In the same way, in the process of IT system construction, due to limited budget and resources, different types of sub-domains should have different attention and resource investment strategies. Remember that good steel should be used wisely.

The business of many companies looks similar on the surface, but the business model and strategic direction are very different, so the focus of the company will be different. When dividing the core domain, general domain and support domain, the results will also be very different. big difference. For example, Taobao, Tmall, JD.com and Suning.com, which are all e-commerce platforms, have different business models. Taobao is a C2C website, individual sellers to individual buyers, while Tmall, JD.com and Suning.com are B2C websites, corporate sellers to individual buyers. Even if Suning.com and JD.com are both B2C models, their business models are different. Suning.com is a typical traditional offline store transformed into an e-commerce store, while JD.com is a direct sales plus some platform model.

Different business models will lead to different results of core domain division. The core domain of some companies may be in customer service, some may be in product quality, and some may be in logistics. When subdividing the company's domain, establishing a domain model and system construction, we must combine the company's strategic focus and business model to find the core domain and focus on the core domain.

If your company just intends to transform the microservice architecture, I suggest that you and your technical team should prioritize the construction of the core domain, preferably with absolute control and independent research and development capabilities. If resources are really limited, You can think of a way in the support domain or the general domain, and it is not a bad idea to temporarily use outsourcing.

Summarize

The core idea of ​​the domain is to subdivide the problem domain step by step to reduce the complexity of business understanding and system implementation. Through domain subdivision, gradually narrow the problem domain that microservices need to solve, and build a suitable domain model, and the domain model is mapped into a system to become a microservice.

The main goal of the core domain, supporting domain and general domain is to distinguish the different functional attributes and importance of different sub-domains in the company through domain division, so that the company can adopt different resource investment and construction strategies for different sub-domains. The degree will also be different.

Guess you like

Origin blog.csdn.net/zgz15515397650/article/details/130529004
Recommended