vendredi 21 décembre 2018

What is the benefit of not returning anything for commands in the CQS pattern?

It's clear to me that performing some kind of modification to the underlying data when I do a "query" in a class would be misleading, like making getMyValue() do some kind of side effect. That would be difficult to reason about. But if I do some kind of update like updateModel, I don't see the problem with having it return a query, such as returning the correct state of an entity. I would assume that an error in the update would cause an exception to be thrown. Not returning any values just makes extra work to do a query.

What regrets would I have if I return values with commands in CQS?

Aucun commentaire:

Enregistrer un commentaire