In many businesses, like banking, judiciary, medicine, and law, modifying or changing the data is a crime.
Every time you mutate a state of the object or modify a record in a SQL database you lose the state in which it was before.
“The currency of the future is data”
We all know that the currency of the future is data. We don’t know what tools and methods we will have at our disposal in a decade, we certainly can’t predict how important that data could be for our businesses or for us personally, Still, we design and develop applications that are constantly murdering valuable data.
Why do we model CRUD (create, read, update, delete) based systems? Part of the reason is that it requires little skill to model. A CRUD based system is a telltale sign of domain-anemia which reflects no one has really paid attention to design a proper domain model.
Event sourcing is a way of persisting domain events (the changes that have occurred over time) in your application, that series of events determine the current state of the application.
Few advantages of using an append-only datastore
- A complete log of changes
- Time-traveling (replaying events is like storytelling)
- Easy anomaly and fraud detection (by log comparison)
- Death of cannot reproduce or Easy debugging (production data can be debugged in a development environment)
- Read (with CQRS) and Write performance
- Scalability (with CQRS)
Historical records can be used to perform analysis, and identify interesting patterns. We must consider ES when accountability is critical (e.g Banking, medicine, law).
If your system by nature is Event-driven then using ES is a natural choice (gaming, stock monitoring, real-estate, vehicle tracking, social media).
You should also consider this pattern If you need to maintain versions or historical data, for example, source control systems, document handling, Wikis etc.
Most people think embracing append-only database modeling is complex, however, I believe in the opposite. All the mature industries like Banking, Finance, Law, and Medicine already use these methods, even before computers were invented.
We simply can’t destroy the data, we can’t predict what tools will be available in a year from now, and how useful this data could be in the future.