The premise of reading this article is that you are familiar with the domain-driven design (DDD) and cqrs architecture.
The domain model diagram is as follows:
Note:
- The above domain model draws on the idea of DDD and cqrs during design;
- The idea of DDD is used to design the entity, value object, aggregation, and aggregation root. In the figure, there are three aggregation root types: Forum, thread, and user; the thread aggregation root aggregates the post and viewcounter objects. The post object is the reply of the thread. Obviously, leaving the post object is meaningless, but the post object has a local ID in the thread aggregation, that is, it can be unique under the current thread and does not need to be globally unique.
- The introduction of cqrs makes sure that we do not have to consider how to store the statistical information generated by object association when designing a domain model, so that the domain model can be simplified and clearer; for example, the total number of replies to the post, the latest reply time, and the latest reply to the post. This information is only used for statistics and is only displayed on the interface, that is, we only need this information when querying, so it can be implemented on the Q-side of cqrs.
- The introduction of cqrs can also simplify warehousing, without the need to provide interfaces for querying domain objects and Displaying results on the interface, you only need to provide operations for querying a single aggregation root, add, and remove;
- The above domain model only focuses on the basic functions of a standard forum;
I learned a lot of theoretical knowledge before, and now it is time to use some modeling examples to train. I believe you will have many questions, so I hope you can discuss them more. It's a bit late tonight. I can't write down the entire thinking process. I will make up later.