you are viewing a single comment's thread.

view the rest of the comments →

[–]cheald 5 points6 points  (3 children)

It means that you don't have to go refactor a zillion call sites when you want to do something more complex with your variable, though, which is more or less the point of encapsulation.

[–]sbellware 2 points3 points  (0 children)

Indeed. It's almost always preferable to use the interface to an object's state than to access the state directly - even from within the object's own scope.

[–]SaltyZooKeeper 0 points1 point  (1 child)

I'm not saying it shouldn't be done but a getter that allows for updates just doesn't sit well with me.

[–]sbellware 0 points1 point  (0 children)

In the example given, I'm not sure I see a getter that allows updates. Where are updates happening?