Eventuous videos
I finally opened a YouTube channel for Eventuous.
The first video published there is the one that I call “The power of the transient state”.
Here is a summary of the video.
In an event-sourced system, you don’t need to keep the entity state in any database as a structured state-based model. You normally keep entity events, which must be accessible for fast reading. When you can easily read all the events for a single entity, as you do with EventStoreDB using entity streams, you can easily reconstruct the state on the fly from the events. Doing so eliminates the impedance mismatch altogether because you don’t need to map the domain model entity state to any database model.
One of the benefits of not storing the updated state in addition to storing events is that you can change the representation of the state and the logic to rebuild it from events at any time without breaking anything. You can add and remove properties, convert primitive types to value objects, change an array to an immutable list, and so on. As soon as you persist the state in a structured model, it is locked to the structure of that model. It means when you need to change the state object format, it will stop being compatible with the structured model, and you’d need to execute a database migration to change the structured model and its schema. Even worse, if you are missing data in the structured model, you can only retrofit it by executing an import from another data source. When the state is always rebuilt from events, you can use any information stored in those events as the data source. You can even use events themselves without applying them to the state. This approach brings a lot of freedom to iterate on the needs of the domain model when it comes to analysing the state for making decisions.
In the video, I also show the Eventuous Spyglass, a tool that helps you debug event-sourced applications by going back and forth in time and seeing how different events change the entity state.