Separating command and query responsibilities
Before jumping to the implementation of events in the monolith, let’s look at CQRS. This concept was introduced in the Towards cleaner and more maintainable code section in Chapter 5, Introducing Refactoring Principles. To review the flow of CQRS, you can refer to Figure 5.6 in the same section. So, if you need a refresher on its origin and fundamental workings, go back for a quick review before reading further.
In Chapter 6, Transitioning from Chaos, we started refactoring our monolith, and the last thing missing is to implement CQRS without events yet.
The key concept of CQRS is the separation of responsibilities of reading and writing data within a system. In a typical application, the same model is often used for both querying (reading) and updating (writing) data. However, with CQRS, these concerns are separated into distinct models; the command model (write model) is responsible for handling commands, which are operations...