Shared knowledge between Query model and Command model

106 views
Skip to first unread message

Andrew Cairns

unread,
Jul 15, 2015, 5:08:31 AM7/15/15
to ddd...@googlegroups.com
Hey!

I have a simple boolean I need to return as part of a query.

The problem I have is that this true/false is determined by quite complex logic.
On the write side, it loads other aggregates and asks them to do some calculation also.

I'm adding the query model now, however I do not want to have multiple sources of truth for this logic.

I imagine the answer is projection - have this calculation happen when an event happens, and project it to the read side.
But at the moment, both command and query are using the same data source, and must stay like this for now.

Am I missing something?

Alexander Langer

unread,
Jul 15, 2015, 5:15:19 AM7/15/15
to ddd...@googlegroups.com
If your aggregates do the calculation anyways, can't you just raise a
domain event with the result, which the read side listens for?
> --
> You received this message because you are subscribed to the Google
> Groups "DDD/CQRS" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to dddcqrs+u...@googlegroups.com
> <mailto:dddcqrs+u...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

Alexander Langer

unread,
Jul 15, 2015, 5:17:14 AM7/15/15
to ddd...@googlegroups.com
Sorry, misunderstood the second part. If it must stay as is, I'd put
the calculation part into an individual class in your domain model and
use it from the read side to re-perform the calculation (single source
of knowledge).

Andrew Cairns

unread,
Jul 15, 2015, 7:33:15 AM7/15/15
to ddd...@googlegroups.com
Thanks Alexander,

This makes a lot of sense - I can easily extract a specification for this logic.
It does actually make sense to do this also, in the context of the domain.

Thanks for you help!

a.
Reply all
Reply to author
Forward
0 new messages