What is Domain Model
In Domain Driven Design, Domain Model is the organized and structured knowledge of the business problem. Represents as a diagram, code examples, or written documentation, and must be accessible and understandable by everyone involved with the project.
Components of Domain Model
The vocabulary and key concepts of the domain, and the relationships among all of the entities. These are mainly divided into Domain Events, Commands, Aggregates, and Bounded Context:
Domain Events
A statement in past tense describes the things that happened in a business system that alternates the state of the entity. e.g: Order submitted, Shopping cart updated.
Commands
A verb in present tense describes the action that triggers the corresponding domain event. It is either user or system actions.
- e.g:
Add product
(Command) ->Shopping cart updated
(Domain event)
Aggregates
Represented by a minimal cluster of associated objects(domain events, commands, and actors) that we treat as a unit for data change. Each has a boundary and only exposes its root (Aggregate Root) which allows other objects to reference it.
- e.g: A team wants to update its member role according to each project:
Project, Update member role
(Aggregate Root) ->Project's member role updated
Bounded Context
A high-level structure consists of categorizations of functionality, represents a circle or square, that groups related entities together. It can bound parts of an aggregate or multiple aggregates.
- e.g: In an aggregate for the shopping process, we draw the bounded contexts for Shopping cart, and Offers: Shopping cart (
User
->Add product to cart
->Cart updated
) -> Offers (Promotiational Offers Identified
->Offers added
)