Emerging patterns
In this section, we will cover the following two emerging patterns:
- Domain events: They enforce consistency between multiple aggregates of the same domain
- Event sourcing: This is a way of persisting the application's state and finding the current state by traversing through the history of those saved states
Domain events
The domain event pattern is a preferred a way to trigger side effects across multiple aggregates within the same domain. A domain event is an event that occurs in a particular domain, which the other parts of the same domain (subdomain) should also be aware of and may need to react to it as well.

A domain event pattern helps to do the following:
- Express the side effects of an event in a domain explicitly
- Maintain consistency of the side effects (either all the operations related to the business task are performed or none of them are)
- Enable a better separation of concerns among classes within the same domain
Event sourcing
Event sourcing provides simplification of...