Awesome, that makes total sense!
The main difference I spot is that we didn’t use events towards the UI.
We pushed delta’s of the view / query model instead.
A model as was desired by the UI.
This last point pushes me in circles, where I start moving to your end of the argument.
Need to give this some thought.
This is the freedom of choice you have when going for CQRS. You can optimize for what’s most important. If that’s quick ASAP results, then a model per query might be the way. That doesn’t mean you use it for all the models though, as the non-functional requirements per model differ. It’s just as fine to have some models focused on DRY for (I’d guess) performance reasons, as it is to use a good old RDBMS with a ton of joins because the relationships is what you need. Or that you use a graph-, time-series, or text-based-search-database.
Back to the point though, I’m not stating it for pure DRY reasons.
From the UI perspective, I catch your drift.
I’d wager my stance originates from using a global approach to any type of querying within your application, so not restricted to how REST works.
The basic example we use (within our training material for example) is that of the wish to know the price of a product. So, there’s some form of
WhatIsThePriceForProductQuery out there.
This object dictates the API, which at first likely is just a
A new feature request pops in, where consumers owning a form of discount/premium card get a discount automatically.
cardId is attached to the API in a version 2 of the application.
Another form of feature request you could think off is a general date window of sales (around Christmas for example), which would impact the price result.
One way to implement this is by adjusting the service that performs the query.
Another way to tackle this is by adding another query handler that provides a different answer to the query altogether.
The latter means you don’t have to adjust your UI component (likely a REST endpoint) to return the prices at all. Furthermore, it’s more similar to some real-world scenarios, where you’d ask a group of people/things for something, instead of always having a single authoritative unit.
Just dropping it here, but it might be nice to have a face-to-face conversation somewhere in the future… Just let me know if that’s something you’d be interested in!