CQRS Ignite

@rhwy

alt.net fr talks #17.01

WHY?

(no silverbullet, always ask why!)

overcomplicated

architecture ?

One model from MS P&P

Exemple

And what about the code?

Too many files, concepts ...

Text

https://github.com/tpierrain/CQRS

So what?

Too complex for our real crudy day to day business line applications?

CQRS

1/ 

!=

Event Sourcing

(even if eventsourcing can't help a lot!)

NO!

2/ Should I use and master DDD to use it?

DDD is a toolbox that you should use in coherence, but also some parts only

Command & query

What is it then?

Responsability

Segregation

Greg Young

(Architecture pattern)

https://cqrs.files.wordpress.com/2010/11/cqrs_documents.pdf

Command & query

ok, and for my code?

SePARATION

Bertrand Meyer

(object oriented software)

https://en.wikipedia.org/wiki/Command%E2%80%93query_separation

https://www.amazon.com/gp/product/0136291554

Asking a question should not change the answer

At the method level,

...works at Object level too!

Let's take a Repository

IProductRepository

GetAll()

New(product)

Remove(id)

Update(id,values)

Sounds good, but what happen under load?

In production?

IProductRepository

GetAll()

Get(id)

New(product)

Remove(id)

Update(id,values)

1 x New

10 x Update

1000000 x Get()

Split it into 2 dedicated interfaces (ISP remember?)

IProductRepository

GetAll()

Get(id)

New(product)

Remove(id)

Update(id,values)

IProductQueries

GetAll()

Get(id)

New(product)

Remove(id)

Update(id,values)

IProductCommands

Then implementations can have different life cycles!

ProductQueries

GetAll()

Get(id)

New(product)

Remove(id)

Update(id,values)

ProductCommands

SQL DB

REDIS CACHE

SEGREGATE ALSO

AT DB LEVEL

1st step in CQRS

COULD BE TO USE

TABLES FOR WRITES

AND MATERIALIZED VIEWS FOR READS!

ProductsTable

ProductsCatalog View

Indexes

Insert into 
ProductsTable
Select from

ProductsCatalogView

WHAT's NEXT?

Try that, baby steps

then go deeper with DDD, ES

CQRS Ignite

By Rui Carvalho

CQRS Ignite

  • 556