Opinions about command-query separation

Two thoughts:

(1) there is value in the rule you state, and value in knowing why you’re breaking it. Also, it’s not as common as you think, that one wants to break it. But OTOH, the two examples I cite come up over and over in data-backed systems. And, frankly, in other systems too.

(2) Especially when designing systems where data is accessed via RPC, there are STRONG reasons for breaking the rule, viz: a seminal paper by Jim Gray, where he explains why one must never provide direct SQL (or query) access to a remote database, but instead provide a stored-procedure level of access. That is to say, do not break apart operations that naturally go together, simply in order to abide by the stated rule.

System design isn’t a simple thing, and there are lots of conflicting tensions.

1 Like