Presentation is loading. Please wait.

Presentation is loading. Please wait.

Similar presentations


Presentation on theme: ""— Presentation transcript:

1

2

3

4

5

6 A single model caring about all aspects of the domain is hard. Command/Query Separation (cit. Bertrand Meyer – 1980s ) Query > Returns data > Doesn’t alter state Command > Alter state > Doesn’t return data

7 Presentation layer Application layer Infrastructure layer Domain Model Domain layer Presentation layer Infrastructure layer CQRS Queries Commands

8  We faced a lot of complexity in modeling  We thought it was inherent domain complexity  That more likely resulted from the Cartesian product of queries and commands O( C x Q ) vs. O( C + Q )

9  Regular Transaction Script in the Command stack Query stack (LET or SQL)  Premium Domain Model in the Command stack Ad-hoc read model  Deluxe Domain Model and events (sourcing) in the Command stack Ad-hoc read model (with snapshots) …

10  Transaction Script Task-based, end-to-end use-case implementation One core “transactional” method per user action Not strictly model based, “it-just-works” approach Money-back guarantee!  Two-layer query stack Just queries: LINQ-to-Entities, ADO.NET No models; just DTOs

11

12  Layered Expression Trees  It’s an idiom  Make queries speak the ubiquitous language  Composition of IQueryable extension methods IQueryable up to the application layer  DSL-like expressivity

13 As a business unit manager, I want to collect credits for all outgoing invoices still unpaid Database How to use ubiquitous language while querying.IssuedInvoices.PerBusinessUnit(businessUnitId).Unpaid().Select(i => new { }); InvoiceNumber = i.Number, CustomerId = i.Customer.Id

14

15  Domain Model in the Command stack Domain Model focused on behavior that alters state  Ad-hoc storage for queries in the Query stack Table-per-view strategy Query through LET C C Q Q

16  Domain Model in the Command stack Domain Model focused on behavior that alters system ‘s state Events in the building of tasks Optionally, events as the primary data source  Ad-hoc storage for queries in the Query stack Table-per-view strategy Query through LET Data snapshots and replay of events

17 1.Command takes effect 2.System’s state changes 3.Changes notified through events to registered subscribers (aka, handlers) Workflow managers (aka, sagas) Denormalizers (used to generate ad-hoc views) Application sends a command to the system Typically: events are notified and commands executed via a mediator (aka, bus)

18

19 Application Layer Read stack Domain Layer Handlers

20 SQL XXXMongoDBRavenDB Everyone’s skills Ecosystem of tools On-Premise & cloud Free Linux and Windows On-Premise & cloud Schemaless LINQ support TX+DTC support Schemaless On-Premise & cloud MSMQNEventStoreNServiceBus Lots of code Free FOSS DDD/CQRS/ES full stack Advanced config Advanced features

21

22

23

24

25

26


Download ppt ""

Similar presentations


Ads by Google