Disclaimer:This Isn’t All AboutCommand Query
ResponsibilitySegregation
does anyone here even know what CQRS is anyway, or were the other sessions full?
Another Disclaimer:There won’t be any code,
I don’t do code,just opinions
My Objective Today
My Objective Todayis to Make You Think
My Objective Todayis to Make You Think
“Maybe There Is A Better Way?”
Why Don’t We Talk Like “Normal” People Do?
Why Don’t We Talk Like “Normal” People Do?
Developers are usually techy
Why Don’t We Talk Like “Normal” People Do?
Developers are usually techy
Business people usually don’t understand “techy”
Why Don’t We Talk Like “Normal” People Do?
Developers are usually techy
Business people usually don’t understand “techy”
So why do we try to make them think like we do?
Why Does Language Matter So Much?
Why Does Language Matter So Much?
Without language, we cannot convey meaning
Why Does Language Matter So Much?
Without language, we cannot convey meaning
But when we talk different languages, we lose in the translation
Why Does Language Matter So Much?
Without language, we cannot convey meaning
But when we talk different languages, we lose in the translation
Let’s agree on one
How Do “Normal” People See the World?
How Do “Normal” People See the World?
People don’t think in terms of “data”
How Do “Normal” People See the World?
People don’t think in terms of “data”
People think “tasks”
How Do “Normal” People See the World?
People don’t think in terms of “data”
People think “tasks”
People are objective based, only computers work on data
Otherwise Known As “Grid Abuse”
Otherwise Known As “Grid Abuse”
Grids are a UI problem created by developers
Otherwise Known As “Grid Abuse”
Grids are a UI problem created by developers
People don’t see information in columns and rows
Otherwise Known As “Grid Abuse”
Grids are a UI problem created by developers
People don’t see information in columns and rows
Even Excel doesn’t force you to think that way
If People Don’t Think In Grids, Why Force Data Into Grids?
If People Don’t Think In Grids, Why Force Data Into Grids?Developers are ingrained with RDBMS Rows and Columns
If People Don’t Think In Grids, Why Force Data Into Grids?Developers are ingrained with RDBMS Rows and Columns
Business information doesn’t come in rows and columns
If People Don’t Think In Grids, Why Force Data Into Grids?Developers are ingrained with RDBMS Rows and Columns
Business information doesn’t come in rows and columns
We forced them to store and use it that way
Thinking AboutNoSQL Databases
Thinking AboutNoSQL Databases
If users think about things like “my documents” maybe we should just store stuff that way?
Thinking AboutNoSQL Databases
If users think about things like “my documents” maybe we should just store stuff that way?
NoSQL databases let us concentrate on what to store, not how
Quick Summary
Quick Summary
People need to communicate
Quick Summary
People need to communicate
People think Tasks
Quick Summary
People need to communicate
People think Tasks
People think “stuff” or “documents” or “things”
What Does This Have to Do With CQRS ???
What Does This Have to Do With CQRS ???
Not much ...
What Does This Have to Do With CQRS ???
Not much ...
Yet...
What Does This Have to Do With CQRS ???
Not much ...
Yet...
One more step... now we get a bit techy
CAP Theory
CAP Theory
Consistency: The client perceives that a set of operations has occurred all at once.
CAP Theory
Consistency: The client perceives that a set of operations has occurred all at once.
Availability: Every operation must terminate in an intended response.
CAP Theory
Consistency: The client perceives that a set of operations has occurred all at once.
Availability: Every operation must terminate in an intended response.
Partition tolerance: Operations will complete, even if individual components are unavailable.
CAP Theory
Consistency: The client perceives that a set of operations has occurred all at once.
Availability: Every operation must terminate in an intended response.
Partition tolerance: Operations will complete, even if individual components are unavailable.
You cannot have all three
ACID
ACID
Atomic, Consistent, Isolated, Durable
ACID
Atomic, Consistent, Isolated, Durable
In CAP Theory terms ACID gives you:
ACID
Atomic, Consistent, Isolated, Durable
In CAP Theory terms ACID gives you:
Consistency and Availability
ACID
Atomic, Consistent, Isolated, Durable
In CAP Theory terms ACID gives you:
Consistency and Availability
But Sacrifices Partition Tolerance
BASE
BASE
Basically Available, Soft state, Eventually consistent
BASE
Basically Available, Soft state, Eventually consistent
In CAP Theory BASE gives you:
BASE
Basically Available, Soft state, Eventually consistent
In CAP Theory BASE gives you:
Availability and Partition Tolerance
BASE
Basically Available, Soft state, Eventually consistent
In CAP Theory BASE gives you:
Availability and Partition Tolerance
But Sacrifices Consistency
Command Query Responsibility Segregation
Command Query Responsibility Segregation
Bertrand Meyer principle of CQS:every method should either be a command that performs an action, or a query that returns data to the caller
Command Query Responsibility Segregation
Bertrand Meyer principle of CQS:every method should either be a command that performs an action, or a query that returns data to the caller
At an architectural level this means:either issue commands, or issue queries, but never both
Command Query Responsibility Segregation
Bertrand Meyer principle of CQS:every method should either be a command that performs an action, or a query that returns data to the caller
At an architectural level this means:either issue commands, or issue queries, but never both
And, query from a separate source from your domain commands
CQRS and BASE
CQRS and BASE
CQRS gives us BASE at an architectural level
CQRS and BASE
CQRS gives us BASE at an architectural level
We may not always be consistent
CQRS and BASE
CQRS gives us BASE at an architectural level
We may not always be consistent
But most data isn’t consistent in reality anyway, we just think it is
CQRS and BASE
CQRS gives us BASE at an architectural level
We may not always be consistent
But most data isn’t consistent in reality anyway, we just think it is
Eventually our architecture will be consistent
CQRS in a Picture
Client
Domain
Command
Persist
PublishEvent HandlersEvent Handlers
Update
Queries
(synchronous no bus)
Domain Persistence Read Model
CQRS in a Simpler Picture
Domain Read Model
Client
Comm
andsDT
Os
Events
What Did All That Beginning Stuff Have to Do With CQRS ???
What Did All That Beginning Stuff Have to Do With CQRS ???
The way people think matters
What Did All That Beginning Stuff Have to Do With CQRS ???
The way people think matters
CQRS splits actions from queries
What Did All That Beginning Stuff Have to Do With CQRS ???
The way people think matters
CQRS splits actions from queries
And people think about asking people to do things or asking them for information
Benefits of CQRS
Benefits of CQRS
Simplified Architecture
Benefits of CQRS
Simplified Architecture
Closer Alignment with Users
Benefits of CQRS
Simplified Architecture
Closer Alignment with Users
Performance
Benefits of CQRS
Simplified Architecture
Closer Alignment with Users
Performance
Scalability
Benefits of CQRS
Simplified Architecture
Closer Alignment with Users
Performance
Scalability
Eliminates a leaky abstraction
My Objective Todaywas to Make You Think
My Objective Todaywas to Make You Think
“Maybe There Is A Better Way?”
My Objective Todaywas to Make You Think
“Maybe There Is A Better Way?”
I Hope I Succeeded
DeveloperDeveloperDeveloper! Events would not be possibleWith out the generous support from our sponsors…We would like to thank the following for their support: