vendredi 9 novembre 2018

design a method returning a value or changing some data but not both

I vaguely remember reading somewhere a while ago that either a method/function should return a value without modifying the state or should process some data changing a state but not returning data. It is beyond simple getters and setters.

I cannot figure where I read that, the rationale and if this was a sound principle. It may be simpler to test for sure but is there any other reason? Is there is there a related design principle or pattern? Any clue or link appreciated.

Thanks Olivier

Aucun commentaire:

Enregistrer un commentaire