Tom Janssens
unread,Jun 30, 2011, 7:40:26 AM6/30/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ddd...@googlegroups.com
What kind of analysis do you use ? Start with BDD, and you get your commands and events for free.
An AR is just a class that groups together a series of command handlers that share state. Group your commands and you are halfway there...
A saga is a class that groups together things that happened in 1-n AR's (=events), or a timeout. It can publish a command if conditions are met. I tend to create a lot of small sagas respecting SRP.
If 2 AR's share a lot of saga's, it *might* be an indication that one of them is not an AR, but part of the other one.
You should not make it this hard; just do what your gut feeling tells you to do. The rules of CQRS are simple:
Command => AR.Command(command.parameters) => *Event
Event => *AR.Handle(Event)
*Event|Timeout => *Saga.Handle(Event|Timeout) => *Command
Event => QuerymodelBuilder.Handle(Event)
Due to the separation AR's come naturally, and cross-AR-transitions are explicit which makes it easy to spot problems in the flow or missing sagas, it also makes refactoring effortless.
Everywhere I look I see a lot of complicated explanations, I prefer KISS; if you use the CQRS approach, you do not need DDD, it comes naturally with it. I consider CQRS a methodology that makes it hard not to do DDD. Respect CQRS rules, and you will see your flow comes naturally.
One of the biggest benefits of CQRS is IMO that, due to the distinct separation, it does not cost you much if you make a mistake. Since everything is subdivided in small, manageable units, they are *a lot* easier to maintain/change.. CQRS allows you to fix errors easily. Errors are part of the learning proces; do not fight them, but accept them and learn from your mistakes.