The Event Sourcing pattern
The Event Sourcing pattern stores state changes as a sequence of events, allowing the reconstruction of past states and providing an audit trail. This pattern is particularly useful in systems where the state is complex and the business rules for transitions are complex.
As we will see in implementation examples later, the Event Sourcing pattern emphasizes the importance of capturing all changes to an application state as a sequence of events. An outcome of this is that the application state can be reconstructed at any point in time by replaying these events.
Real-world examples
There are several real-world examples in the software category:
- Audit trails: Keeping a record of all changes made to a database for compliance
- Collaborative editing: Allowing multiple users to edit a document simultaneously
- Undo/redo features: Providing the ability to undo or redo actions in an application