3 ms·
For me a setter is something that refers explicitly to data inside the object. It means the world outside the object is now intimately and inappropriately conce
by lacampbell 9y ago
For me a setter is something that refers explicitly to data inside the object. It means the world outside the object is now intimately and inappropriately concerned with what's inside the object. The whole point of objects is to make them block boxes and ask them to do higher level things, and hide how they do those things to avoid information overload.
Even if a method does nothing but set an internal field of an object, in my eyes it's not a setter if it performs an actual high level task and doesn't expose the internal structure. IE:
monster.setDead(true);
Is a setter. While
monster.Kill();
Is not to me, even if it does the exact same thing inside. The latter doesn't bother me about internal details like some boolean field called "dead".
It's a subtle and almost pedantic distinction, but I hope you see where I'm coming from, and can appreciate the mindshift change from "this is a box full of fields" to "this is an entity".
- betenoire 9y agoThank you :) this is the answer I've been waiting for