Managing the application's lifecycle

Entities and aggregations are all about managing this cycle at every level of the application. We can think about the application itself being the aggregation wrapped around all its components to manage the attached value objects and contained entities. At the level of our prisoner transfer, we treat the transfer itself as a transaction wrapping all the local dependents, and managing the eventual result of either a successful transfer or a failed one.

It is always possible to push the lifecycle management further up or down the chain of objects, and finding the right level can be hard. In the previous example, the assignment might as well be a value object managed by an aggregate up the chain to ensure its constraints ...

Get JavaScript Domain-Driven Design now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.