Tactical Design With Aggregaates
Tactical Design With Aggregaates
Aggregates
CHAPTER 5
Introduction
▪ Tactical DDD is a set of design patterns and building blocks that you
can use to design domain-driven systems.
▪ Even for projects that are not domain-driven, you can benefit from
using some of the tactical DDD patterns.
▪ Tactical design deals with classes and modules.
▪ The purpose of tactical design is to refine the domain model to a
stage where it can be converted into working code.
Recap…
Context Mapping
• Each of the circled concepts that you see inside these two Bounded Contexts is an
Aggregate.
• The one concept not circled—Discussion —is modeled as a Value Object.
Entity
▪ An entity is an object whose identity is of importance.
▪ unique ID that is assigned when the entity is created and remains unchanged throughout the
lifespan of the entity
▪ Two entities of the same type and with the same ID are considered the same entity.
▪ Entities are mutable.
▪ Carefully model the setters of the entities.
What is a Value Object?
▪A Value Object models an immutable conceptual whole. Within the
model the Value is just that, a value.
▪ Instead of changing the state of the value object, you replace it with a new instance.
▪ A factory can be a static factory method on the aggregate root class or a separate factory class.
▪ The factory can interact with other factories, repositories and domain services but must never
alter the state of the database (so no saving or deleting).
Code example…
Modules