The CQS pattern
Command-Query Separation (CQS) is a design principle that clearly distinguishes between commands that change the state of an object or system and queries that return values without changing the state. CQS focuses on the simplicity and clarity of operations within a single system.
Command Query Responsibility Segregation (CQRS) extends the CQS concept to a broader architectural level. While CQRS inherits CQS’s separation of commands and queries, it applies it across separate models for reading and writing, often resulting in distinct read and write data stores. This segregation facilitates scaling and optimizing the two operations independently, which can be especially beneficial in complex, high-demand, or distributed systems. However, that complexity can bring potential data synchronization challenges. CQRS is often paired with event sourcing and event-driven architectures. We explore that in Chapter 19, Introduction to Microservices Architecture.
In...