Many seem to mix CQRS (the architectural pattern) to this lot simpler practice that Martin describes. Check the post again 😊
They're very much related though. Interestingly if you look at what he says, He in fact determines that changing state and returning values should be deemed as two separate operations.
"It would be nice if the language itself would support this notion. I could imagine a language that would detect state changing methods, or at least allow the programmer to mark them. "
This one could argue is Martin himself notioning that using a void function should be called a "command", and a standard function that returns an object is called a "query". I'd go along with that, and a way of the compiler enforcing that rule would be even better!
"The really valuable idea in this principle is that it's extremely handy if you can clearly separate methods that change state from those that don't. This is because you can use queries in many situations with much more confidence, introducing them anywhere, changing their order. You have to be more careful with modifiers."
This is where the problem lies, your return type functions can still change global state, and this is where I feel we are not enforcing enough rules around what a function "should/is allowed" to do.
Thanks for sharing your views, I appreciate the healthy debate!
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.