Suppose I have a class Foo, with a private variable bar_ containing some state for Foo. If necessary, I may write public get/set metho
Foo
bar_
It's better to use the get and set methods: It's cleaner, upholds DRY principles better (only do validation once), and allows subclasses to override the methods and see consistent behavior on all changes to the variable.
get
set