No.jon ninpoja wrote:. . . do getters and setters let me create an object with these variables always set to a specific value? . . .
Stephan van Hulst wrote:
Agree: isn't that what OO is all about. Let theStephan van Hulst wrote:. . .
The problem is that we're not really using the power of object oriented programming here. If we're only interested in the distance between two points, then why are we asking about the x and the y coordinates? If we are only ever interested in the distance, we can get rid of the x and y getters, and just add a distance property:
Surely you would use this method rather than sqrt? It promises not to overflow, but that probably doesn't apply to the arguments, where there is a risk of integer overflow.
. . .
jon ninpoja wrote:
Getters and setters are often criticized as being not proper OO. On the other hand most OO code I've seen has extensive getters and setters.
And in these scenarios we would have to trust that people using the objects would be careful not to break encapsulation?Bear Bibeault wrote:. . . the bean pattern, to include getters and setters, is required in many scenarios. . . .
There are three kinds of actuaries: those who can count, and those who can't.
They worship nothing. They say it's because nothing lasts forever. Like this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|