domain driven design and cqrs
play

Domain-Driven Design and CQRS Xebia ITR on Command Query - PowerPoint PPT Presentation

Domain-Driven Design and CQRS Xebia ITR on Command Query Responsibility Separation Sjors Grijpink and Erik Rozendaal DDD Eric Evans, Domain- Driven Design, 2004 Key concepts Ubiquitous Language Value Object, Entity


  1. Domain-Driven Design and CQRS Xebia ITR on Command Query Responsibility Separation Sjors Grijpink and Erik Rozendaal

  2. DDD • Eric Evans, Domain- Driven Design, 2004 • Key concepts • Ubiquitous Language • Value Object, Entity • Aggregate

  3. Ubiquitous Language • Language shared between domain experts and developers • No need for error-prone translation • Maps directly to domain implementation • Implementation should be free of “technical” terms

  4. Value Object • No conceptual identity • Describe characteristic of a thing • Usually immutable • Examples: Address, Money, ...

  5. Entity • Something with a unique identity • Identity does not change when any of its attributes change • Examples: Customer, Order, ...

  6. Aggregate • Group of Entities & Value Objects • One entity within the aggregate is the aggregate root • All access to the objects inside go through the root entity • Aggregates are consistency boundaries

  7. Lottery • Two aggregate roots Lottery Customer • Lottery • Customer Ticket

  8. 3 Tier • Presentation layer is denormalized • Domain is behavioral • Transactional database is normalized

  9. “A single model cannot be appropriate for reporting, searching, and transactional behaviors.” - Greg Young

  10. Purchase Lottery Ticket

  11. Purchase Lottery Ticket Lottery Ticket Purchased

  12. Purchase Lottery Find Lottery Ticket Tickets for Customer Lottery Ticket Purchased

  13. All state changes are represented by Domain Events

  14. Domain

  15. Reporting

  16. Packages Domain Presentation Reporting Commands Events Queries

  17. Packages Domain Presentation Reporting Shared Commands Events Queries

  18. Packages Domain Presentation Reporting framework Shared CQRS Commands Events Queries

  19. Exercise 1 • Implement “Create Customer” • Test that customers are listed on the screen • Test that customers cannot be created with an initial payment of less than 10.00

  20. Exercise 2 • Implement “Purchase Lottery Ticket” • Ticket should be listed • Customer’s balance should be updated • Don’t forget to check the customer’s account balance

  21. Benefits

  22. Benefits • Fully encapsulated domain that only exposes behavior

  23. Benefits • Fully encapsulated domain that only exposes behavior • Queries do not use the domain model

  24. Benefits • Fully encapsulated domain that only exposes behavior • Queries do not use the domain model • No object-relational impedance mismatch

  25. Benefits • Fully encapsulated domain that only exposes behavior • Queries do not use the domain model • No object-relational impedance mismatch • Bullet-proof auditing and historical tracing

  26. Benefits • Fully encapsulated domain that only exposes behavior • Queries do not use the domain model • No object-relational impedance mismatch • Bullet-proof auditing and historical tracing • Easy integration with external systems

  27. Benefits • Fully encapsulated domain that only exposes behavior • Queries do not use the domain model • No object-relational impedance mismatch • Bullet-proof auditing and historical tracing • Easy integration with external systems • Performance and scalability

  28. Benefits • Fully encapsulated domain that only exposes behavior • Queries do not use the domain model • No object-relational impedance mismatch • Bullet-proof auditing and historical tracing • Easy integration with external systems • Performance and scalability • Testability

  29. Bounded Context

  30. Advanced Topics • Snapshots • Command-event conflict resolution • Eventual consistency • Transaction-aware repository • ...

  31. Snapshot Repository load save Event Store 4 snapshot 3 2 1 0

  32. The End • Eric Evans, Domain-Driven Design • Greg Young, Unshackle Your Domain

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend