狠狠撸

狠狠撸Share a Scribd company logo
…WHAT’S THAT CQRS
THING?
introduction for adopters
effect
free!
COMMAND QUERY
RESPONSIBILITY
SEGREGATION PATTERN
ORIGINAL SIN
CREATE
READ
UPDATE
DELETE
...hai detto CQRS a chi ?!?!?!
...hai detto CQRS a chi ?!?!?!
is an architectural pattern proposed by Greg
Young that segregates reads and writes of a
system into two separate subsystems.
CQRS
writes are usually asynchronous and
stored in a transactional storage while
reads are eventually consistent and
retrieved from de-normalised views
CQRS (details)
BERTRAND MAYER
Designer of Eiffel
programming language
Coined “open/closed
principle” and “design
by contract”
Introduced command
query separation
(CQS)
Use of commands and queries separates write and read concerns
COMMAND
Tell to do something
COMMAND
? Command is the message to change state
? Message handled by a CommandHandler
? Returns void (so nothing)
? Describes business intent
? Immutable
QUERY
Fetch state from data store
QUERY
? Read state from data store
? Does not change state
? Has a return value
WHY SHOULD I USE CQRS?
? Scalability
? Reduced complexity
? Flexibility
? Focus on the business
? Fear of change
? Mental leap
? All-Or-Nothing approach
BE AWARE OF
CQRS MYTHS
? is easy
? CQRS = Event Sourcing and vice versa
? requires an eventual consistent read store
? requires a bus/queues/asynchronous messaging
– Udi Dahan
“Most people using CQRS (and event sourcing too)
shouldn't have done so”
– GregYoung
“It's important to note though, that these are things you
can do, not necessarily things you should do.
Separating the read and write models can be quite costly”
WHEN SHOULD I AVOID IT?
WHATS NEXT?
? Event sourcing (ES)
? Eventual consistency
? Task based UI
? …
...hai detto CQRS a chi ?!?!?!
Thank you.
@realfuzzy
Michele Franzin
CREDITS
slide10 - www.defenceimagery.mod.uk - 45155579
slide 12 - https://www.?ickr.com/photos/broeckxsven/
slides 4,9 - http://martinfowler.com/bliki/
http://martinfowler.com/bliki/CQRS.html
http://udidahan.com/2009/12/09/clari?ed-cqrs/
https://en.wikipedia.org/wiki/Command–query_separation
https://cqrs.?les.wordpress.com/2010/11/cqrs_documents.pdf
RESOURCES

More Related Content

...hai detto CQRS a chi ?!?!?!