4 ms·
Yup, this is very true. As long as you return something deterministic, unit testing is easy. It's where you need to handle mutable state with objects that thin
by disgruntledphd2 6y ago
Yup, this is very true. As long as you return something deterministic, unit testing is easy.
It's where you need to handle mutable state with objects that things get trickier.
Unfortunately, these are exactly the places where you most need tests.
I'm a big fan of constantly returning things rather than holding state in objects, for specifically this reason.
- HelloNurse 6y agoA basic issue of encapsulation: objects shouldn't rely on the mutable state of something else, but only on their own.