Member-only story
EVENT SOURCING — THE PRIVILEGED MODEL FOR INDIRECTION — PART 1
“We can solve any problem by introducing an extra level of indirection” — Event Sourcing is the privileged model to do it.
The idea of Event Sourcing is the following: to capture and save the changes of an application state as events. Before the term has been coined by Martin Fowler, the idea was referred as the Append-Only-Log, Write-Ahead-Log or simply the Log.
Capturing and saving all the application changes has the advantage of allowing to know the state of the application for any given instant and also to know how it got there. Event Sourcing brings two key features: the time dimension and the warranty that no information is lost. The time dimension is obvious to note, as every state change is saved in a time ordered serie. Depending on the events naming, reading an Event Log can be as informal as reading a journal, check this event history:
UserRegistered -> UserEmailValidated -> UserAddedHomeAddress -> UserUploadedProfilePicture -> UserAddedHobby -> UserRequestedToJoinGroup -> UserMarried -> UserChangedHomeAddress -> UserChangedProfilePicture.
It’s obvious the sequence of changes the user performed. We not only see the user changed the home address but we can see he did it after marrying. By saving all changes we can at any time answer questions like: how…