You guys and girls have any opinions about this design principle?
It states that every method should either be a command that performs an action, or a query that returns data to the caller, but not both. In other words, asking a question should not change the answer . More formally, methods should return a value only if they are referentially transparent and hence possess no side effects.
A counter-example would a function like
read_file. It’s not referential transparent, but it does at least not change the answer (writes anything).
Another interesting topic is how to enforce this principle in language semantics.
NB that even in Haskell, nothing prevents the coder from spamming IO monad everywhere.