hai detto cqrs a chi ?!?!?!
TRANSCRIPT
…WHAT’S THAT CQRS THING?
introduction for adopters
effect
free!
COMMAND QUERY RESPONSIBILITY
SEGREGATION PATTERN
ORIGINAL SIN
CREATE
READ
UPDATE
DELETE
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 MAYERDesigner 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
COMMANDTell to do something
COMMAND• Command is the message to change state
• Message handled by a CommandHandler
• Returns void (so nothing)
• Describes business intent
• Immutable
QUERYFetch 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”
– Greg Young
“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
• …
Thank you.
@realfuzzyMichele Franzin
CREDITSslide10 - www.defenceimagery.mod.uk - 45155579slide 12 - https://www.flickr.com/photos/broeckxsven/slides 4,9 - http://martinfowler.com/bliki/
http://martinfowler.com/bliki/CQRS.htmlhttp://udidahan.com/2009/12/09/clarified-cqrs/https://en.wikipedia.org/wiki/Command–query_separationhttps://cqrs.files.wordpress.com/2010/11/cqrs_documents.pdf
RESOURCES