Book Image

JavaScript Domain-Driven Design

Book Image

JavaScript Domain-Driven Design

Overview of this book

Table of Contents (15 chapters)
JavaScript Domain-Driven Design
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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 are satisfied. The right level of abstraction at this stage is a decision that the developers of the system have to make. Pushing the transaction control too high and then making the transaction span more objects can be costly as the locks...