Are you aware that storing and updating current state means loosing important data?
Event sourcing is a way to solve this problem. It is the technique of storing state transitions rather than updating the current state itself.
Event sourcing has some more benefits:
- Complete audit-proof log for free
- Complete history of every state change ever
- No more mapping objects to tables
- Distribution support
- CQRS (Command Query Responsibility Segregation) support
- Natural fit for domain-driven design and functional programming
- Be prepared for unanticipated use cases in the future (for free)
State transitions are an important part of our problem space and should be modelled within our domain -- Greg Young
When I first encountered the concept of event sourcing and CQRS and looked at some sample applications, I had the impression that it must be extremely difficult to implement. But later I found out that event sourcing is easier than I first thought, especially when it is expressed with functional programming.
Here are 12 things about event sourcing that should help you to get started today.