Open hawkins6423 opened 8 years ago
I've been working on a project where we've been having similar discussions regarding ReST -> Command translation, but we've come up with a different approach. The general mapping of POST/DELETE to a default Create/Delete command is the same, but as you imply, the difficulty is in the space between, updating, where semantic meaning is harder to infer.
We ended up doing things slightly differently, as we found that even if you were doing something like "ChangeColor" from your example, that wouldn't imply enough about the semantic meaning of the change. For example, we might be bored of the color, the color might be wrong, the color might need re-applying, etc.
What we ended up doing was modelling types of actions against a sub-resource where appropriate. So you might have had the following:
GET /cars/1
GET /cars/1/color
POST /cars/1/color/changes
POST /cars/1/color/corrections
Maybe not the best example, but each intent was modelled as a collection of intents that had been applied to that resource. Posting to /cars/1/color/corrections
would map to a CorrectColor command, for example.
I think this adds a different type of complexity, but I'm definitely interested in discussing it, because in many places the trigger pattern feels potentially more elegant - but more lossy?
Opinions welcomed :)
There seems to be a good amount if interest regarding emerging CQRS patterns. I recently made a blog post on the Trigger Pattern (see ReST vs CQRS: The Trigger Pattern http://hawkins6423.github.io/) and I would like to open it up to the community to discuss.
I'll commit the code used in the blog post once I clean it up!