This document discusses Command Query Responsibility Segregation (CQRS). It begins by explaining that CQRS splits commands and queries into separate paths at an architectural level. This aligns with how people think about tasks (commands) and requesting information (queries) differently. The document then discusses how CQRS provides an eventually consistent architecture based on CAP theorem, similar to BASE. It explains that CQRS reads data from a separate read model than where commands write to the domain model. In summary, CQRS separates commands from queries in a way that matches how people think, and provides an eventually consistent architecture.
9. Why Don’t We Talk Like
“Normal” People Do?
Developers are usually
techy
10. Why Don’t We Talk Like
“Normal” People Do?
Developers are usually
techy
Business people usually
don’t understand “techy”
11. 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?
13. Why Does Language
Matter So Much?
Without language, we
cannot convey meaning
14. Why Does Language
Matter So Much?
Without language, we
cannot convey meaning
But when we talk
different languages, we
lose in the translation
15. 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
17. How Do “Normal” People
See the World?
People don’t think in
terms of “data”
18. How Do “Normal” People
See the World?
People don’t think in
terms of “data”
People think “tasks”
19. 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
21. Otherwise Known As
“Grid Abuse”
Grids are a UI problem
created by developers
22. Otherwise Known As
“Grid Abuse”
Grids are a UI problem
created by developers
People don’t see
information in columns
and rows
23. 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
25. If People Don’t Think In Grids,
Why Force Data Into Grids?
Developers are ingrained
with RDBMS Rows and
Columns
26. 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
27. 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
29. Thinking About
NoSQL Databases
If users think about
things like
“my documents” maybe
we should just store
stuff that way?
30. Thinking About
NoSQL 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
41. 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.
42. 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.
43. 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
52. BASE
Basically Available, Soft state, Eventually
consistent
In CAP Theory BASE gives you:
Availability and Partition Tolerance
53. BASE
Basically Available, Soft state, Eventually
consistent
In CAP Theory BASE gives you:
Availability and Partition Tolerance
But Sacrifices Consistency
56. 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
57. 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
60. CQRS and BASE
CQRS gives us BASE at an architectural
level
We may not always be consistent
61. 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
62. 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
63. CQRS in a Picture
Client
Command
Queries
Domain Event Handlers
Event Handlers
Publish (synchronous no bus)
Persist Update
Domain Persistence Read Model
64. CQRS in a Simpler Picture
Domain Events Read Model
Co
Os
m
m
DT
an
ds
Client
65. What Did All That Beginning
Stuff Have to Do With CQRS ???
66. What Did All That Beginning
Stuff Have to Do With CQRS ???
The way people think matters
67. What Did All That Beginning
Stuff Have to Do With CQRS ???
The way people think matters
CQRS splits actions from queries
68. 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
CQRS is a technical approach that solves a lot of problems
But it requires something more, a better way of working
So this presentation is more about how to think differently
You don’t ring your bank and say “I want you to view my customer record, edit the address fields and save it to your database”
You do call your bank and say “I would like to change my correspondence address”
You don’t ring your bank and say “I want you to view my customer record, edit the address fields and save it to your database”
You do call your bank and say “I would like to change my correspondence address”
You don’t ring your bank and say “I want you to view my customer record, edit the address fields and save it to your database”
You do call your bank and say “I would like to change my correspondence address”
Users think of lists of information ... my tweets, my bank account transaction, my facebook wall, my auctions, my Documents
This abuse extends to many areas of a business - we have abused users into talking our way, not theirs
Users think of lists of information ... my tweets, my bank account transaction, my facebook wall, my auctions, my Documents
This abuse extends to many areas of a business - we have abused users into talking our way, not theirs
Users think of lists of information ... my tweets, my bank account transaction, my facebook wall, my auctions, my Documents
This abuse extends to many areas of a business - we have abused users into talking our way, not theirs
Store data in a loose fashion
Only store what you need
In the format you want
Store data in a loose fashion
Only store what you need
In the format you want