Command and Query Responsibility Segregation Cameron Fletcher
Agenda What is CQRS? A look at a system that uses CQRS What have we just seen? Why would anybody ever do this?
What is CQRS?
Command and Query Responsibility Segregation CQRS is simply the creation of two objects where there was previously only one. The separation occurs based upon whether the methods are a command or a query.
DenormalizerApplication Fully Consistent Data Store Eventually Consistent Data Store Command ServiceQuery Service Client
A Look at a System that uses CQRS
What Have We Just Seen?
Architecture Domain Application Fully Consistent Write Model Denormalizer Eventually Consistent Read Model Command and Query Services Task Based User Interface
Putting Things into Context
Why Would I Ever Do This?
Advantages Performance and Scalability Separation of Concerns Reduced Complexity of Domain Ability to Parallelize Development Highly Decoupled Increased Testability Easier to Adapt to Change
Disadvantages Increased Complexity of Architecture Learning Curve for Developers Fear of Change
When Not To Use CQRS (In This Way) Lack of Requirements No Domain to Work With If the Benefit isn’t Worth It When it’s not Useful On a System as a Whole Not Just for Scalability Legacy Systems
Summary
Questions?