In Chapter 9, CQRS - The Read Side, we changed our application to use events as the consistent aggregate storage. Instead of updating a snapshot of the state after handling a command, we can add new events to the stream that represents a single aggregate. We can then do a left fold on those events to reconstruct the aggregate state each time we load it again, before handling another command. In two lines of pseudo code, the essence of Event Sourcing can be represented as follows:
// Loading: state = foreach(event in history: state = when(state, event)) // Command handling: event = handle(state, command)
Here, history is what we load from the aggregate stream, when is the AggregateRoot.When method and Handle is one of the methods in the application service.
But, as I mentioned before, I removed all read models and the code associated with queries from the...