Wrap Up

Aggregates are all about persistence and transactions. In fact, you can't design Aggregates without thinking about how they're going to be persisted. The basic rules to design proper Aggregates are: make them small, find true business invariants, push for eventual consistency using Domain Events, reference other Aggregates by Identity, and modify one Aggregate per request. Review how the code changes if two Entities form a single Aggregate or not. Use factories to enrich your Entities. Finally, relax. In most of the PHP applications we've seen, only five percent of the Entities were Aggregates formed by two Entities or more. Discuss with your workmates when designing and implementing Aggregates.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset