CQRS – Eine Einführung                        .Net Online Usergroup – 10.10.2011                                   Present...
What CQRS is NOT
DDD revisitedUsual Patterns ▫ Entities ▫ Value Objects ▫ Repositories
DDD revisitedSome Important Patterns ▫   Ubiquitous Language ▫   Bounded Contexts ▫   Core Domain ▫   Domain Experts
DDD RevisitedAn Example: Competitive advantage through an efficient online claims procedure
DDD revisitedDO use DDD: ▫ Where we get competitive advantage
DDD revisitedDO use DDD: ▫ Where we get competitive advantageDON‘T use DDD ▫ When there‘s no value in formalizing the prob...
DDD revisited• The point of DDD is not Software Analysis
DDD revisited• The point of DDD is not Software Analysis• It‘s Business Analysis
„Best-Practice“ Architecture
„Best-Practice“ Architecture
„Best-Practice“ Architecture• Pros: ▫ Easy to build ▫ Accepted by management ▫ Well known
„Best-Practice“ Architecture• Cons: ▫   Limited scalability ▫   Loss of intent ▫   Lazy Loading ▫   Data Projection ▫   Pa...
Domain Model Responsibilities•   Business Logic•   Validation•   Structure•   Associations•   Scopes, Filters•   Aggregati...
The S in SOLID
Read vs. Write• Reads and Writes are completely different from  eachother• Why do we try to build the One Model to  Rule T...
Command-Query Separation• Bertrand Meyer: ▫ Every method should either be a command that   performs an action, or a query ...
CQS on an Architectural Level          Queries                    Commands     Project    Project              Project    ...
Basic CQRS Architecture                     Data Storage               ORM                 Thin Read Layer         Domain ...
The Parts: Thin Read Layer• Concerns: ▫ Filtering, Scope ▫ Data Presentation• Attributes ▫   Data-Oriented ▫   Indexable ▫...
The Parts: Domain Model• Concerns:  ▫ Validation  ▫ Business Logic• Attributes:  ▫   Normalized  ▫   Object Oriented  ▫   ...
The Parts: Task-Based UI
The Parts: Task-Based UI
The Parts: Task-Based UI
The Parts: CommandsRefactoring: Application Service Calls to ObjectsCommands: ▫   Are Serializable ▫   Can be enveloped ▫ ...
The Parts: Command HandlersRefactoring: Application Service to Command HandlerCommand Handlers: ▫ Unify interface to all a...
This is CQRS! Complicated?                     Data Storage               ORM                 Thin Read Layer         Doma...
But what about Eventual Consistency?
The First Rule             Source: www.kinoweb.de
CQRS can be perfectly consistent!                     Data Storage               ORM                 Thin Read Layer      ...
Advanced topics for another day•   Events•   Sagas•   Event Log•   Messaging•   Service Busses•   NoSQL•   Event Store
Thanks! Dennis Traub   @DTraub
Resources• cqrsinfo.com• groups.google.com/group/dddcqrs• distributedpodcast.com
CQRS - Eine Einführung - NOUG 2011
CQRS - Eine Einführung - NOUG 2011
Upcoming SlideShare
Loading in …5
×

CQRS - Eine Einführung - NOUG 2011

1,106 views
953 views

Published on

Published in: Self Improvement, Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,106
On SlideShare
0
From Embeds
0
Number of Embeds
38
Actions
Shares
0
Downloads
14
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

CQRS - Eine Einführung - NOUG 2011

  1. 1. CQRS – Eine Einführung .Net Online Usergroup – 10.10.2011 Presenter: Dennis Traub Speaker, Author, Software Developer since 1991 Currently at ProAvia GmbH, Stuttgart Twitter: @DTraub
  2. 2. What CQRS is NOT
  3. 3. DDD revisitedUsual Patterns ▫ Entities ▫ Value Objects ▫ Repositories
  4. 4. DDD revisitedSome Important Patterns ▫ Ubiquitous Language ▫ Bounded Contexts ▫ Core Domain ▫ Domain Experts
  5. 5. DDD RevisitedAn Example: Competitive advantage through an efficient online claims procedure
  6. 6. DDD revisitedDO use DDD: ▫ Where we get competitive advantage
  7. 7. DDD revisitedDO use DDD: ▫ Where we get competitive advantageDON‘T use DDD ▫ When there‘s no value in formalizing the problem
  8. 8. DDD revisited• The point of DDD is not Software Analysis
  9. 9. DDD revisited• The point of DDD is not Software Analysis• It‘s Business Analysis
  10. 10. „Best-Practice“ Architecture
  11. 11. „Best-Practice“ Architecture
  12. 12. „Best-Practice“ Architecture• Pros: ▫ Easy to build ▫ Accepted by management ▫ Well known
  13. 13. „Best-Practice“ Architecture• Cons: ▫ Limited scalability ▫ Loss of intent ▫ Lazy Loading ▫ Data Projection ▫ Pain ▫ And: If Domain is only CRUD, where does Business Logic live?
  14. 14. Domain Model Responsibilities• Business Logic• Validation• Structure• Associations• Scopes, Filters• Aggregation• Presentation• Persistence• Lazy / Eager Loading• …
  15. 15. The S in SOLID
  16. 16. Read vs. Write• Reads and Writes are completely different from eachother• Why do we try to build the One Model to Rule Them All?• Sometimes it‘s cheaper to do two things than dealing with the trade-offs
  17. 17. Command-Query Separation• Bertrand Meyer: ▫ Every method should either be a command that performs an action, or a query that returns data to the caller• In other words: ▫ Asking a question should not change the answer.
  18. 18. CQS on an Architectural Level Queries Commands Project Project Project Details List Data Storage
  19. 19. Basic CQRS Architecture Data Storage ORM Thin Read Layer Domain Model Command Handlers Commands Queries Client
  20. 20. The Parts: Thin Read Layer• Concerns: ▫ Filtering, Scope ▫ Data Presentation• Attributes ▫ Data-Oriented ▫ Indexable ▫ Can be Denormalized for fast access ▫ Only Structure
  21. 21. The Parts: Domain Model• Concerns: ▫ Validation ▫ Business Logic• Attributes: ▫ Normalized ▫ Object Oriented ▫ Transactional ▫ Persistence Ignorant ▫ Only Behaviour
  22. 22. The Parts: Task-Based UI
  23. 23. The Parts: Task-Based UI
  24. 24. The Parts: Task-Based UI
  25. 25. The Parts: CommandsRefactoring: Application Service Calls to ObjectsCommands: ▫ Are Serializable ▫ Can be enveloped ▫ Can be intercepted ▫ Can be enriched ▫ Communicate intent
  26. 26. The Parts: Command HandlersRefactoring: Application Service to Command HandlerCommand Handlers: ▫ Unify interface to all application services ▫ Can be wrapped (e.g. Transaction, Authorization, Logging, etc.) ▫ Can be enveloped (e.g. RESTful Envelope) ▫ Rule of Thumb: One Command Handler per Use Case
  27. 27. This is CQRS! Complicated? Data Storage ORM Thin Read Layer Domain Model Command Handlers Commands Queries Client
  28. 28. But what about Eventual Consistency?
  29. 29. The First Rule Source: www.kinoweb.de
  30. 30. CQRS can be perfectly consistent! Data Storage ORM Thin Read Layer Domain Model Command Handlers Commands Queries Client
  31. 31. Advanced topics for another day• Events• Sagas• Event Log• Messaging• Service Busses• NoSQL• Event Store
  32. 32. Thanks! Dennis Traub @DTraub
  33. 33. Resources• cqrsinfo.com• groups.google.com/group/dddcqrs• distributedpodcast.com

×