Organize the business logic as a collection of procedural transaction scripts, one for each type of request.
Organize the business logic as an object model consisting of classes that have state and behavior.
- Entity
- Value Object
- Subdomains
核心子域, 通用子域和支撑子域, ’子域’,和‘‘限界上下文”在大多数情况下是一对一或者一对多的映射关系。
- Factory
- Repository
- Aggregate
- Service
- Bounded contenxt(限界上下文) 即限定了边界的上下文环境。 在—个明媚的早晨,孩子起床问妈妈:, ‘今天应该穿几件衣 服呀?”妈妈回答:‘‘能穿多少就穿多少!’,那到底是穿多还是穿少呢?
Organize a domain model as a collection of aggregates, each of which is a graph of objects that can be treated as a unit.
Ensure that an aggregate is a self-contained unit that can enforce its invariants.
- 避免跨服务的Object reference, 即是多个Aggregate通过外键的值相互关联,而不是对象的引用。
- 一个事务只能更新创建和更新单个Aggregate,Aggregate满足Microservice的事务模型约束。
An aggregate publishes a domain event when it’s created or undergoes some other significant change.
从现象到本质
从现象到抽象(即模式)
黑盒子
- 熟悉业务场景和业务流程
- 将技术能力匹配到业务上
即模式应用能力