DDD: "four-color prototype" for "aggregation design"

Source: Internet
Author: User
ArticleDirectory
    • Image Diagram
    • Glossary
    • Business trip management example
    • Step 1: recognize models
    • Step 2: Identify Association
    • Step 3: partition Aggregation
    • Step 4: streamline Association
Four-color prototype

In the context of enterprise applications, the four-color prototype is a prototype of the domain model, which means that any model in the domain and its relationship can be abstracted as a "four-color prototype ".

The four-color prototype can be described in this sentence: a person's (Party) role (partyrole) uses a thing in a place role (placerole) the role (thingrole) does something (momentinterval ).

Image Diagram

Glossary
    • Partplacething (PPT for short): Commonly Used ppt files include departments, positions, personnel, locations, and items.
    • Description: it is short for Des, which is expressed in light blue. It is mainly used to describe PPT. Common des include department type, job level, personnel type, location and region, and item category.
    • Role: indicates the role of a PPT in a specific scenario. Common roles include finance departments, management jobs, leave-offs, sales points, and products.
    • Momentinterval: MI in short. It is represented in light red. It mainly indicates one thing that occurs at a moment or within a period of time. Common MI: department movement, position movement, employee resignation, product sales, etc.
    • Momentinteval: midetail in short. It is represented in light red, mainly in MI details. Common midetail includes sales details, warehouse receiving details, and warehouse picking details.
Business trip management example

Perform aggregation design based on four-color prototype (step 4) Step 1: The recognition model can easily identify the domain model based on the four-color prototype (SEE ). Step 2: Identify associations based on four-color prototypes It is also easy to identify the relationships between domain models (see ). Step 3: partition Aggregation
    • Mi and midetail are an aggregation, and MI is an aggregation root.
    • A ppt is an aggregation, and a PPT is an aggregation root. If des only describes "ppt", it will belong to the aggregation of the PPT as a value object.
    • Des is an aggregation, and DES is an aggregation root. If you want to "track" the slides associated with DES.
    • Role is not an aggregation service. role is a stateful domain service. Role uses the decorator mode to decorate the PPT.

Division result

Step 4: streamline Association
    • Remove the association between Mi and role, change it to Warehouse query, and associate MI with a role snapshot (the status of the role at the time of occurrence) as needed ). The reason for changing the Association to Warehouse query is that this is more flexible. A person who asks for leave has 1 million application orders, and there is no need to set such association. The reason for associating MI with a role snapshot is that Mi records the status of the role at the time of occurrence in many cases. For example, if a business trip ticket is to record the organization information of the person who asks for leave at the time of occurrence, instead of the current organization information.
    • The association between ppt and DES can be kept as appropriate based on my hobbies. I like to use warehouse query, which is more flexible.
    • Remove the association between ppt and role and change it to Warehouse query. For example, you can use the warehouse to find the PPT and inject the PPT instance into the role.

Simplified results

Why is the details of a sales order and a sales order aggregated, and the articles and comments are not aggregated? Because the sales order is Mi, the sales order details are midetail, so they are an aggregation; the article is Mi, and the comment is Mi, so they are not an aggregation. Remarks

The four-color prototype can help us with aggregation design. I kicked the problem of aggregation design to the four-color prototype analysis. This article has not discussed in detail how to identify the four-color prototype in the field. Of course, there are other rules for aggregation design to follow. Let's discuss them later. Time is limited. I will use happyframework to write a demo later.

Today, I haven't talked much about the issue of "Responsibility Assignment". The four-color prototype can perfectly supplement various models of DDD's Responsibility Assignment. I will discuss it in the next topic.

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.