In the previous article, we introduced Event Sourcing and identified one of the primary disadvantages of event sourcing when a single aggregate root couldn't answer our queries. In this article, we present a solution to the problem: Command Query Request Segregation.
It is a fact of life that applications will have defects. The process of remediating an error is straightforward. Write a unit test to reproduces the defect (if one doesn't already exist) and then modify the defective source code until the unit test passes. But how do we fix data that has been corrupted by the faulty code? If we use the common CRUD approach, we store only the current state of an entity. In this situation, we have no way of knowing how we arrived at that state. This article explores the Event Sourcing approach as a means to address the problem.