Top Banner
Stuff About CQRS Jak Charlton @JakCharlton [email protected]
78

Stuff About CQRS

Jan 29, 2018

Download

Technology

thinkddd
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Stuff About CQRS

Stuff About CQRS

Jak Charlton@JakCharlton

[email protected]

Page 2: Stuff About CQRS

Disclaimer:This Isn’t All AboutCommand Query

ResponsibilitySegregation

Page 3: Stuff About CQRS

does anyone here even know what CQRS is anyway, or were the other sessions full?

Page 4: Stuff About CQRS

Another Disclaimer:There won’t be any code,

I don’t do code,just opinions

Page 5: Stuff About CQRS

My Objective Today

Page 6: Stuff About CQRS

My Objective Todayis to Make You Think

Page 7: Stuff About CQRS

My Objective Todayis to Make You Think

“Maybe There Is A Better Way?”

Page 8: Stuff About CQRS

Why Don’t We Talk Like “Normal” People Do?

Page 9: Stuff About CQRS

Why Don’t We Talk Like “Normal” People Do?

Developers are usually techy

Page 10: Stuff About CQRS

Why Don’t We Talk Like “Normal” People Do?

Developers are usually techy

Business people usually don’t understand “techy”

Page 11: Stuff About CQRS

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?

Page 12: Stuff About CQRS

Why Does Language Matter So Much?

Page 13: Stuff About CQRS

Why Does Language Matter So Much?

Without language, we cannot convey meaning

Page 14: Stuff About CQRS

Why Does Language Matter So Much?

Without language, we cannot convey meaning

But when we talk different languages, we lose in the translation

Page 15: Stuff About CQRS

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

Page 16: Stuff About CQRS

How Do “Normal” People See the World?

Page 17: Stuff About CQRS

How Do “Normal” People See the World?

People don’t think in terms of “data”

Page 18: Stuff About CQRS

How Do “Normal” People See the World?

People don’t think in terms of “data”

People think “tasks”

Page 19: Stuff About CQRS

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

Page 20: Stuff About CQRS

Otherwise Known As “Grid Abuse”

Page 21: Stuff About CQRS

Otherwise Known As “Grid Abuse”

Grids are a UI problem created by developers

Page 22: Stuff About CQRS

Otherwise Known As “Grid Abuse”

Grids are a UI problem created by developers

People don’t see information in columns and rows

Page 23: Stuff About CQRS

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

Page 24: Stuff About CQRS

If People Don’t Think In Grids, Why Force Data Into Grids?

Page 25: Stuff About CQRS

If People Don’t Think In Grids, Why Force Data Into Grids?Developers are ingrained with RDBMS Rows and Columns

Page 26: Stuff About CQRS

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

Page 27: Stuff About CQRS

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

Page 28: Stuff About CQRS

Thinking AboutNoSQL Databases

Page 29: Stuff About CQRS

Thinking AboutNoSQL Databases

If users think about things like “my documents” maybe we should just store stuff that way?

Page 30: Stuff About CQRS

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

Page 31: Stuff About CQRS

Quick Summary

Page 32: Stuff About CQRS

Quick Summary

People need to communicate

Page 33: Stuff About CQRS

Quick Summary

People need to communicate

People think Tasks

Page 34: Stuff About CQRS

Quick Summary

People need to communicate

People think Tasks

People think “stuff” or “documents” or “things”

Page 35: Stuff About CQRS

What Does This Have to Do With CQRS ???

Page 36: Stuff About CQRS

What Does This Have to Do With CQRS ???

Not much ...

Page 37: Stuff About CQRS

What Does This Have to Do With CQRS ???

Not much ...

Yet...

Page 38: Stuff About CQRS

What Does This Have to Do With CQRS ???

Not much ...

Yet...

One more step... now we get a bit techy

Page 39: Stuff About CQRS

CAP Theory

Page 40: Stuff About CQRS

CAP Theory

Consistency: The client perceives that a set of operations has occurred all at once.

Page 41: Stuff About CQRS

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.

Page 42: Stuff About CQRS

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.

Page 43: Stuff About CQRS

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

Page 44: Stuff About CQRS

ACID

Page 45: Stuff About CQRS

ACID

Atomic, Consistent, Isolated, Durable

Page 46: Stuff About CQRS

ACID

Atomic, Consistent, Isolated, Durable

In CAP Theory terms ACID gives you:

Page 47: Stuff About CQRS

ACID

Atomic, Consistent, Isolated, Durable

In CAP Theory terms ACID gives you:

Consistency and Availability

Page 48: Stuff About CQRS

ACID

Atomic, Consistent, Isolated, Durable

In CAP Theory terms ACID gives you:

Consistency and Availability

But Sacrifices Partition Tolerance

Page 49: Stuff About CQRS

BASE

Page 50: Stuff About CQRS

BASE

Basically Available, Soft state, Eventually consistent

Page 51: Stuff About CQRS

BASE

Basically Available, Soft state, Eventually consistent

In CAP Theory BASE gives you:

Page 52: Stuff About CQRS

BASE

Basically Available, Soft state, Eventually consistent

In CAP Theory BASE gives you:

Availability and Partition Tolerance

Page 53: Stuff About CQRS

BASE

Basically Available, Soft state, Eventually consistent

In CAP Theory BASE gives you:

Availability and Partition Tolerance

But Sacrifices Consistency

Page 54: Stuff About CQRS

Command Query Responsibility Segregation

Page 55: Stuff About CQRS

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

Page 56: Stuff About CQRS

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

Page 57: Stuff About CQRS

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

Page 58: Stuff About CQRS

CQRS and BASE

Page 59: Stuff About CQRS

CQRS and BASE

CQRS gives us BASE at an architectural level

Page 60: Stuff About CQRS

CQRS and BASE

CQRS gives us BASE at an architectural level

We may not always be consistent

Page 61: Stuff About CQRS

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

Page 62: Stuff About CQRS

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

Page 63: Stuff About CQRS

CQRS in a Picture

Client

Domain

Command

Persist

PublishEvent HandlersEvent Handlers

Update

Queries

(synchronous no bus)

Domain Persistence Read Model

Page 64: Stuff About CQRS

CQRS in a Simpler Picture

Domain Read Model

Client

Comm

andsDT

Os

Events

Page 65: Stuff About CQRS

What Did All That Beginning Stuff Have to Do With CQRS ???

Page 66: Stuff About CQRS

What Did All That Beginning Stuff Have to Do With CQRS ???

The way people think matters

Page 67: Stuff About CQRS

What Did All That Beginning Stuff Have to Do With CQRS ???

The way people think matters

CQRS splits actions from queries

Page 68: Stuff About CQRS

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

Page 69: Stuff About CQRS

Benefits of CQRS

Page 70: Stuff About CQRS

Benefits of CQRS

Simplified Architecture

Page 71: Stuff About CQRS

Benefits of CQRS

Simplified Architecture

Closer Alignment with Users

Page 72: Stuff About CQRS

Benefits of CQRS

Simplified Architecture

Closer Alignment with Users

Performance

Page 73: Stuff About CQRS

Benefits of CQRS

Simplified Architecture

Closer Alignment with Users

Performance

Scalability

Page 74: Stuff About CQRS

Benefits of CQRS

Simplified Architecture

Closer Alignment with Users

Performance

Scalability

Eliminates a leaky abstraction

Page 75: Stuff About CQRS

My Objective Todaywas to Make You Think

Page 76: Stuff About CQRS

My Objective Todaywas to Make You Think

“Maybe There Is A Better Way?”

Page 77: Stuff About CQRS

My Objective Todaywas to Make You Think

“Maybe There Is A Better Way?”

I Hope I Succeeded