Stuff About CQRS

       Jak Charlton
            @JakCharlton
        jak@thinkddd.com
Disclaimer:
This Isn’t All About
Command Query
  Responsibility
   Segregation
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 Today
is to Make You Think
My Objective Today
is 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”
S...
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...
Why Does Language
     Matter So Much?
Without language, we
cannot convey meaning
But when we talk
different languages, we...
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
...
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...
Otherwise Known As
      “Grid Abuse”
Grids are a UI problem
created by developers
People don’t see
information in columns...
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
 Busin...
If People Don’t Think In Grids,
 Why Force Data Into Grids?
 Developers are ingrained
 with RDBMS Rows and
 Columns
 Busin...
Thinking About
NoSQL Databases
Thinking About
     NoSQL Databases
If users think about
things like
“my documents” maybe
we should just store
stuff that ...
Thinking About
      NoSQL Databases
If users think about
things like
“my documents” maybe
we should just store
stuff that...
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 operat...
CAP Theory
Consistency: The client perceives that a set of
operations has occurred all at once.
Availability: Every operat...
CAP Theory
Consistency: The client perceives that a set of
operations has occurred all at once.
Availability: Every operat...
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 Sacrifice...
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 Tole...
BASE

Basically Available, Soft state, Eventually
consistent
In CAP Theory BASE gives you:
Availability and Partition Tole...
Command Query
Responsibility Segregation
Command Query
Responsibility Segregation
Bertrand Meyer principle of CQS:
every method should either be a command that
per...
Command Query
Responsibility Segregation
Bertrand Meyer principle of CQS:
every method should either be a command that
per...
Command Query
Responsibility Segregation
Bertrand Meyer principle of CQS:
every method should either be a command that
per...
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 ...
CQRS and BASE
CQRS gives us BASE at an architectural
level
We may not always be consistent
But most data isn’t consistent ...
CQRS in a Picture
                                 Client


             Command



                                      ...
CQRS in a Simpler Picture

    Domain              Events             Read Model
             Co




                     ...
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...
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 Today
was to Make You Think
My Objective Today
was to Make You Think
 “Maybe There Is A
   Better Way?”
My Objective Today
was to Make You Think
 “Maybe There Is A
   Better Way?”
I Hope I Succeeded
DeveloperDeveloperDeveloper! Events would not be possible
      With out the generous support from our sponsors…
     We w...
Upcoming SlideShare
Loading in …5
×

Stuff About CQRS

3,483 views

Published on

Presentation on CQRS given at DDDSydney on 17 July 2010

Published in: Technology
0 Comments
7 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,483
On SlideShare
0
From Embeds
0
Number of Embeds
550
Actions
Shares
0
Downloads
165
Comments
0
Likes
7
Embeds 0
No embeds

No notes for slide
  • 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










































































  • Stuff About CQRS

    1. 1. Stuff About CQRS Jak Charlton @JakCharlton jak@thinkddd.com
    2. 2. Disclaimer: This Isn’t All About Command Query Responsibility Segregation
    3. 3. does anyone here even know what CQRS is anyway, or were the other sessions full?
    4. 4. Another Disclaimer: There won’t be any code, I don’t do code, just opinions
    5. 5. My Objective Today
    6. 6. My Objective Today is to Make You Think
    7. 7. My Objective Today is to Make You Think “Maybe There Is A Better Way?”
    8. 8. Why Don’t We Talk Like “Normal” People Do?
    9. 9. Why Don’t We Talk Like “Normal” People Do? Developers are usually techy
    10. 10. Why Don’t We Talk Like “Normal” People Do? Developers are usually techy Business people usually don’t understand “techy”
    11. 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?
    12. 12. Why Does Language Matter So Much?
    13. 13. Why Does Language Matter So Much? Without language, we cannot convey meaning
    14. 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. 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
    16. 16. How Do “Normal” People See the World?
    17. 17. How Do “Normal” People See the World? People don’t think in terms of “data”
    18. 18. How Do “Normal” People See the World? People don’t think in terms of “data” People think “tasks”
    19. 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
    20. 20. Otherwise Known As “Grid Abuse”
    21. 21. Otherwise Known As “Grid Abuse” Grids are a UI problem created by developers
    22. 22. Otherwise Known As “Grid Abuse” Grids are a UI problem created by developers People don’t see information in columns and rows
    23. 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
    24. 24. If People Don’t Think In Grids, Why Force Data Into Grids?
    25. 25. If People Don’t Think In Grids, Why Force Data Into Grids? Developers are ingrained with RDBMS Rows and Columns
    26. 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. 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
    28. 28. Thinking About NoSQL Databases
    29. 29. Thinking About NoSQL Databases If users think about things like “my documents” maybe we should just store stuff that way?
    30. 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
    31. 31. Quick Summary
    32. 32. Quick Summary People need to communicate
    33. 33. Quick Summary People need to communicate People think Tasks
    34. 34. Quick Summary People need to communicate People think Tasks People think “stuff” or “documents” or “things”
    35. 35. What Does This Have to Do With CQRS ???
    36. 36. What Does This Have to Do With CQRS ??? Not much ...
    37. 37. What Does This Have to Do With CQRS ??? Not much ... Yet...
    38. 38. What Does This Have to Do With CQRS ??? Not much ... Yet... One more step... now we get a bit techy
    39. 39. CAP Theory
    40. 40. CAP Theory Consistency: The client perceives that a set of operations has occurred all at once.
    41. 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. 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. 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
    44. 44. ACID
    45. 45. ACID Atomic, Consistent, Isolated, Durable
    46. 46. ACID Atomic, Consistent, Isolated, Durable In CAP Theory terms ACID gives you:
    47. 47. ACID Atomic, Consistent, Isolated, Durable In CAP Theory terms ACID gives you: Consistency and Availability
    48. 48. ACID Atomic, Consistent, Isolated, Durable In CAP Theory terms ACID gives you: Consistency and Availability But Sacrifices Partition Tolerance
    49. 49. BASE
    50. 50. BASE Basically Available, Soft state, Eventually consistent
    51. 51. BASE Basically Available, Soft state, Eventually consistent In CAP Theory BASE gives you:
    52. 52. BASE Basically Available, Soft state, Eventually consistent In CAP Theory BASE gives you: Availability and Partition Tolerance
    53. 53. BASE Basically Available, Soft state, Eventually consistent In CAP Theory BASE gives you: Availability and Partition Tolerance But Sacrifices Consistency
    54. 54. Command Query Responsibility Segregation
    55. 55. 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
    56. 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. 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
    58. 58. CQRS and BASE
    59. 59. CQRS and BASE CQRS gives us BASE at an architectural level
    60. 60. CQRS and BASE CQRS gives us BASE at an architectural level We may not always be consistent
    61. 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. 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. 63. CQRS in a Picture Client Command Queries Domain Event Handlers Event Handlers Publish (synchronous no bus) Persist Update Domain Persistence Read Model
    64. 64. CQRS in a Simpler Picture Domain Events Read Model Co Os m m DT an ds Client
    65. 65. What Did All That Beginning Stuff Have to Do With CQRS ???
    66. 66. What Did All That Beginning Stuff Have to Do With CQRS ??? The way people think matters
    67. 67. What Did All That Beginning Stuff Have to Do With CQRS ??? The way people think matters CQRS splits actions from queries
    68. 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
    69. 69. Benefits of CQRS
    70. 70. Benefits of CQRS Simplified Architecture
    71. 71. Benefits of CQRS Simplified Architecture Closer Alignment with Users
    72. 72. Benefits of CQRS Simplified Architecture Closer Alignment with Users Performance
    73. 73. Benefits of CQRS Simplified Architecture Closer Alignment with Users Performance Scalability
    74. 74. Benefits of CQRS Simplified Architecture Closer Alignment with Users Performance Scalability Eliminates a leaky abstraction
    75. 75. My Objective Today was to Make You Think
    76. 76. My Objective Today was to Make You Think “Maybe There Is A Better Way?”
    77. 77. My Objective Today was to Make You Think “Maybe There Is A Better Way?” I Hope I Succeeded
    78. 78. DeveloperDeveloperDeveloper! Events would not be possible With out the generous support from our sponsors… We would like to thank the following for their support:

    ×