SlideShare una empresa de Scribd logo
1 de 14
Jonathan Oliver Command 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 Perspective Why are we doing this? It’s a “Best Practice”. The way it’s always been done.
A Few Problems UI Services / Caching Bottlenecks Caching Scalability Translation code Impedance mismatch Race conditions Stale data Business Logic DAL Database
Stale Data? Get data Get data Stale data Update data
Queries If it’s stale anyway… List of Customers ……………………. ……………………. ……………………. ……………………. ……………………. (from 10 minutes ago)
A Persistent View Model Read only. Stored in structure used by view. Query Persistent  View Model SELECT * 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 Input What is the user telling us? Do we even know? How? Task-based UIs vs. CRUD-based UIs. Capture user intent explicitly.
Validation and Business Rules Pre-validation from view model. Validation: Is this command complete? String lengths Required fields Regex, etc. Business Rules: Can I do what the user wants? Where is the source of truth?
Good Commands Validated on client. Revalidated on server. Reply can be asynchronous: Amazon
CQRS Image courtesy Udi Dahan
Service Layer Transaction Script. Active Record / Table Module. Domain Model. No Getters/Setters Transactional. Separate database from queries. The “source of truth”.
Questions?

Más contenido relacionado

Similar a CQRS: An Introduction for Beginners

Metric Abuse: Frequently Misused Metrics in Oracle
Metric Abuse: Frequently Misused Metrics in OracleMetric Abuse: Frequently Misused Metrics in Oracle
Metric Abuse: Frequently Misused Metrics in OracleSteve Karam
 
Making & Breaking Machine Learning Anomaly Detectors in Real Life by Clarence...
Making & Breaking Machine Learning Anomaly Detectors in Real Life by Clarence...Making & Breaking Machine Learning Anomaly Detectors in Real Life by Clarence...
Making & Breaking Machine Learning Anomaly Detectors in Real Life by Clarence...CODE BLUE
 
Stream dataprocessing101
Stream dataprocessing101Stream dataprocessing101
Stream dataprocessing101Sotaro Kimura
 
The Semantic Web - This time... its Personal
The Semantic Web - This time... its PersonalThe Semantic Web - This time... its Personal
The Semantic Web - This time... its PersonalMark Wilkinson
 
Application Security at DevOps Speed and Portfolio Scale
Application Security at DevOps Speed and Portfolio ScaleApplication Security at DevOps Speed and Portfolio Scale
Application Security at DevOps Speed and Portfolio ScaleJeff Williams
 
Growing Up MongoDB
Growing Up MongoDBGrowing Up MongoDB
Growing Up MongoDBMongoDB
 
Rental Cars and Industrialized Learning to Rank with Sean Downes
Rental Cars and Industrialized Learning to Rank with Sean DownesRental Cars and Industrialized Learning to Rank with Sean Downes
Rental Cars and Industrialized Learning to Rank with Sean DownesDatabricks
 
What Are We Still Doing Wrong
What Are We Still Doing WrongWhat Are We Still Doing Wrong
What Are We Still Doing Wrongafa reg
 
Presto at Tivo, Boston Hadoop Meetup
Presto at Tivo, Boston Hadoop MeetupPresto at Tivo, Boston Hadoop Meetup
Presto at Tivo, Boston Hadoop MeetupJustin Borgman
 
Geek Sync | Field Medic’s Guide to Database Mirroring
Geek Sync | Field Medic’s Guide to Database MirroringGeek Sync | Field Medic’s Guide to Database Mirroring
Geek Sync | Field Medic’s Guide to Database MirroringIDERA Software
 
Virtual Proteomics Analysis Cluster in the Cloud
Virtual Proteomics Analysis Cluster in the CloudVirtual Proteomics Analysis Cluster in the Cloud
Virtual Proteomics Analysis Cluster in the CloudSimon Twigger
 
AllTheTalks Security Chaos Engineering
AllTheTalks Security Chaos Engineering AllTheTalks Security Chaos Engineering
AllTheTalks Security Chaos Engineering Aaron Rinehart
 
Explaining Black-Box Machine Learning Predictions - Sameer Singh, Assistant P...
Explaining Black-Box Machine Learning Predictions - Sameer Singh, Assistant P...Explaining Black-Box Machine Learning Predictions - Sameer Singh, Assistant P...
Explaining Black-Box Machine Learning Predictions - Sameer Singh, Assistant P...Sri Ambati
 
The limits of unit testing by Craig Stuntz
The limits of unit testing by Craig StuntzThe limits of unit testing by Craig Stuntz
The limits of unit testing by Craig StuntzQA or the Highway
 
The Limits of Unit Testing by Craig Stuntz
The Limits of Unit Testing by Craig StuntzThe Limits of Unit Testing by Craig Stuntz
The Limits of Unit Testing by Craig StuntzQA or the Highway
 
Fault Finder: Identifying Laptop Failures from Amazon Reviews
Fault Finder: Identifying Laptop Failures from Amazon ReviewsFault Finder: Identifying Laptop Failures from Amazon Reviews
Fault Finder: Identifying Laptop Failures from Amazon ReviewsBrendon O'Leary
 
SELJE_Database_Unit_Testing_Slides.pdf
SELJE_Database_Unit_Testing_Slides.pdfSELJE_Database_Unit_Testing_Slides.pdf
SELJE_Database_Unit_Testing_Slides.pdfEric Selje
 

Similar a CQRS: An Introduction for Beginners (20)

Metric Abuse: Frequently Misused Metrics in Oracle
Metric Abuse: Frequently Misused Metrics in OracleMetric Abuse: Frequently Misused Metrics in Oracle
Metric Abuse: Frequently Misused Metrics in Oracle
 
Making & Breaking Machine Learning Anomaly Detectors in Real Life by Clarence...
Making & Breaking Machine Learning Anomaly Detectors in Real Life by Clarence...Making & Breaking Machine Learning Anomaly Detectors in Real Life by Clarence...
Making & Breaking Machine Learning Anomaly Detectors in Real Life by Clarence...
 
Stream dataprocessing101
Stream dataprocessing101Stream dataprocessing101
Stream dataprocessing101
 
The Semantic Web - This time... its Personal
The Semantic Web - This time... its PersonalThe Semantic Web - This time... its Personal
The Semantic Web - This time... its Personal
 
Running a Lean Startup with AWS
Running a Lean Startup with AWSRunning a Lean Startup with AWS
Running a Lean Startup with AWS
 
Application Security at DevOps Speed and Portfolio Scale
Application Security at DevOps Speed and Portfolio ScaleApplication Security at DevOps Speed and Portfolio Scale
Application Security at DevOps Speed and Portfolio Scale
 
mri-bp2015
mri-bp2015mri-bp2015
mri-bp2015
 
Growing Up MongoDB
Growing Up MongoDBGrowing Up MongoDB
Growing Up MongoDB
 
Rental Cars and Industrialized Learning to Rank with Sean Downes
Rental Cars and Industrialized Learning to Rank with Sean DownesRental Cars and Industrialized Learning to Rank with Sean Downes
Rental Cars and Industrialized Learning to Rank with Sean Downes
 
What Are We Still Doing Wrong
What Are We Still Doing WrongWhat Are We Still Doing Wrong
What Are We Still Doing Wrong
 
Presto at Tivo, Boston Hadoop Meetup
Presto at Tivo, Boston Hadoop MeetupPresto at Tivo, Boston Hadoop Meetup
Presto at Tivo, Boston Hadoop Meetup
 
Geek Sync | Field Medic’s Guide to Database Mirroring
Geek Sync | Field Medic’s Guide to Database MirroringGeek Sync | Field Medic’s Guide to Database Mirroring
Geek Sync | Field Medic’s Guide to Database Mirroring
 
Virtual Proteomics Analysis Cluster in the Cloud
Virtual Proteomics Analysis Cluster in the CloudVirtual Proteomics Analysis Cluster in the Cloud
Virtual Proteomics Analysis Cluster in the Cloud
 
AllTheTalks Security Chaos Engineering
AllTheTalks Security Chaos Engineering AllTheTalks Security Chaos Engineering
AllTheTalks Security Chaos Engineering
 
Explaining Black-Box Machine Learning Predictions - Sameer Singh, Assistant P...
Explaining Black-Box Machine Learning Predictions - Sameer Singh, Assistant P...Explaining Black-Box Machine Learning Predictions - Sameer Singh, Assistant P...
Explaining Black-Box Machine Learning Predictions - Sameer Singh, Assistant P...
 
Good sql server interview_questions
Good sql server interview_questionsGood sql server interview_questions
Good sql server interview_questions
 
The limits of unit testing by Craig Stuntz
The limits of unit testing by Craig StuntzThe limits of unit testing by Craig Stuntz
The limits of unit testing by Craig Stuntz
 
The Limits of Unit Testing by Craig Stuntz
The Limits of Unit Testing by Craig StuntzThe Limits of Unit Testing by Craig Stuntz
The Limits of Unit Testing by Craig Stuntz
 
Fault Finder: Identifying Laptop Failures from Amazon Reviews
Fault Finder: Identifying Laptop Failures from Amazon ReviewsFault Finder: Identifying Laptop Failures from Amazon Reviews
Fault Finder: Identifying Laptop Failures from Amazon Reviews
 
SELJE_Database_Unit_Testing_Slides.pdf
SELJE_Database_Unit_Testing_Slides.pdfSELJE_Database_Unit_Testing_Slides.pdf
SELJE_Database_Unit_Testing_Slides.pdf
 

CQRS: An Introduction for Beginners

  • 1. Jonathan Oliver Command QueryResponsibility Segregation
  • 2. Who Cares? “This time, it’s going to be different. Trust me.” “Doctor, it hurts when I do that.” Why?
  • 3. A Question of Perspective Why are we doing this? It’s a “Best Practice”. The way it’s always been done.
  • 4. A Few Problems UI Services / Caching Bottlenecks Caching Scalability Translation code Impedance mismatch Race conditions Stale data Business Logic DAL Database
  • 5. Stale Data? Get data Get data Stale data Update data
  • 6. Queries If it’s stale anyway… List of Customers ……………………. ……………………. ……………………. ……………………. ……………………. (from 10 minutes ago)
  • 7. A Persistent View Model Read only. Stored in structure used by view. Query Persistent View Model SELECT * FROM Table WHERE ID = …
  • 8. 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.
  • 9. Commands and User Input What is the user telling us? Do we even know? How? Task-based UIs vs. CRUD-based UIs. Capture user intent explicitly.
  • 10. Validation and Business Rules Pre-validation from view model. Validation: Is this command complete? String lengths Required fields Regex, etc. Business Rules: Can I do what the user wants? Where is the source of truth?
  • 11. Good Commands Validated on client. Revalidated on server. Reply can be asynchronous: Amazon
  • 12. CQRS Image courtesy Udi Dahan
  • 13. Service Layer Transaction Script. Active Record / Table Module. Domain Model. No Getters/Setters Transactional. Separate database from queries. The “source of truth”.