High-Performance Distributed Systems withCommand/Query Responsibility SegregationJonathan OliverUtah Code Camp 2010
Think DifferentlierBest practices != best thinkingBlind vs intentional applicationQuestion everythingHow much does it cost?
Domain Muddling and ModelingWhat was the original intent?Screen-based aggregate roots?Show domain state?Validation?Get/set, go!
Distributed Systems Architecture
Optimistic and Pessimistic StalemateCollaborative usersCurrent state?Get dataGet dataStale dataUpdate data
LayeringitisWhy go through all the layers?
Tiers for FearsWhy transform across the tiers?DTOs: more code, tests, maintenance, $$$Pre-transformed?
CQRS: Gotta Keep ‘Em SeparatedSOLID, Architectural “S”
Query Query Quite “Contrery”Showing dataQuery-only storageKISS, YAGNIIf it’s stale anywayList of Customers---------------------------------------------------------------(from 10 minutes ago)
All Your Database Are Belong To UsScreen-based viewsUnDRY your data—data duplication“Persistent View Model”Storage/database requirementsScaling outSELECT * FROM Carts WHERE ID = 456;
Queries: SummaryStale data“Persistent View Model”For queries onlyOne table per viewUpdated by eventsData duplication is goodNo table relationshipsNo foreign keys
Command & ConquerSay what?What is a command?Intention revealingSaveInvoicevsPlaceOrderSaveCustomervsMakeCustomerDelinquent
UI DesignExcel-based UIsTask-based UIs
This Time It’s Gonna Be DifferentCan we fully trust user decisions?
Commands and ValidationValidationIs the input potentially good?Ranges, lengths, etcFail fastLeverage persistent view modelUnique emails?Decides if a command should be sentEnables high probability of success
Business RulesShould we do this?Based upon the current system state
Commands: SummaryExpresses intentReply is: “Thank you, we’ve received your input.”AsynchronousAmazonNetflix
Domain Models, Take 2Commands already validatedNo relationships for readingOnly persists what it needsBehavior: Give discounts to high-volume customers
The Big PictureImage courtesy Udi Dahan
The Big Picture: SummarySimple 2-tier queriesCommands express intentTask-based UI captures intentSmaller, more focused pieces
Questions?

High Performance Distributed Systems with CQRS