SlideShare a Scribd company logo
Jonathan OliverCommand QueryResponsibility Segregation
Who Cares?“This time, it’s going to be different.  Trust me.”“Doctor, it hurts when I do that.”Why?
A Question of PerspectiveWhy are we doing this?It’s a “Best Practice”.The way it’s always been done.
A Few ProblemsUIServices / CachingBottlenecksCachingScalabilityTranslation codeImpedance mismatchRace conditionsStale dataBusiness LogicDALDatabase
Stale Data?Get dataGet dataStale dataUpdate data
QueriesIf it’s stale anyway…List of Customers…………………….…………………….…………………….…………………….…………………….(from 10 minutes ago)
A Persistent View ModelRead only.Stored in structure used by view.QueryPersistent  View ModelSELECT * FROM Table WHERE ID = …
That’s Blasphemy!It’s the simplest thing that could possibly work.Testability?Maintainability?Security?Data already shown over the web.It’s already in your cache on the web tier.Role-based SELECTs.
Commands and User InputWhat is the user telling us?Do we even know?How?Task-based UIs vs. CRUD-based UIs.Capture user intent explicitly.
Validation and Business RulesPre-validation from view model.Validation: Is this command complete?String lengthsRequired fieldsRegex, etc.Business Rules: Can I do what the user wants?Where is the source of truth?
Good CommandsValidated on client.Revalidated on server.Reply can be asynchronous:Amazon
CQRSImage courtesy Udi Dahan
Service LayerTransaction Script.Active Record / Table Module.Domain Model.No Getters/SettersTransactional.Separate database from queries.The “source of truth”.
Questions?

More Related Content

RTF
Diags results
 
PPTX
CQRS: Command/Query Responsibility Segregation
PDF
Security vulnerabilities for grown ups - GOTOcon 2012
ODP
Breaking, Entering and Pentesting
PDF
Javaland 2017: "You´ll do microservices now". Now what?
PPTX
Fantastic Tests - The Crimes of Bad Test Design
PDF
Chaos Engineering Without Observability ... Is Just Chaos
KEY
A Very Biased Comparison of MVC Libraries
Diags results
 
CQRS: Command/Query Responsibility Segregation
Security vulnerabilities for grown ups - GOTOcon 2012
Breaking, Entering and Pentesting
Javaland 2017: "You´ll do microservices now". Now what?
Fantastic Tests - The Crimes of Bad Test Design
Chaos Engineering Without Observability ... Is Just Chaos
A Very Biased Comparison of MVC Libraries

Similar to CQRS: An Introduction for Beginners (20)

PPTX
Metric Abuse: Frequently Misused Metrics in Oracle
PDF
Making & Breaking Machine Learning Anomaly Detectors in Real Life by Clarence...
PDF
Stream dataprocessing101
PPTX
The Semantic Web - This time... its Personal
PPTX
Application Security at DevOps Speed and Portfolio Scale
PDF
mri-bp2015
PDF
Growing Up MongoDB
PDF
Rental Cars and Industrialized Learning to Rank with Sean Downes
PPT
What Are We Still Doing Wrong
PDF
Presto at Tivo, Boston Hadoop Meetup
PDF
Geek Sync | Field Medic’s Guide to Database Mirroring
PPT
Virtual Proteomics Analysis Cluster in the Cloud
PPTX
Explaining Black-Box Machine Learning Predictions - Sameer Singh, Assistant P...
PDF
Good sql server interview_questions
PDF
The limits of unit testing by Craig Stuntz
PDF
The Limits of Unit Testing by Craig Stuntz
PPTX
Fault Finder: Identifying Laptop Failures from Amazon Reviews
PDF
SELJE_Database_Unit_Testing_Slides.pdf
PPTX
Learn How to Design, Build and Map Services to Quantifiable Measurements in S...
PDF
Testacular
Metric Abuse: Frequently Misused Metrics in Oracle
Making & Breaking Machine Learning Anomaly Detectors in Real Life by Clarence...
Stream dataprocessing101
The Semantic Web - This time... its Personal
Application Security at DevOps Speed and Portfolio Scale
mri-bp2015
Growing Up MongoDB
Rental Cars and Industrialized Learning to Rank with Sean Downes
What Are We Still Doing Wrong
Presto at Tivo, Boston Hadoop Meetup
Geek Sync | Field Medic’s Guide to Database Mirroring
Virtual Proteomics Analysis Cluster in the Cloud
Explaining Black-Box Machine Learning Predictions - Sameer Singh, Assistant P...
Good sql server interview_questions
The limits of unit testing by Craig Stuntz
The Limits of Unit Testing by Craig Stuntz
Fault Finder: Identifying Laptop Failures from Amazon Reviews
SELJE_Database_Unit_Testing_Slides.pdf
Learn How to Design, Build and Map Services to Quantifiable Measurements in S...
Testacular
Ad

CQRS: An Introduction for Beginners