3 ms·
It's real great to know that I can get and set all the fields. Thanks previous programmer.
by delusional 7y ago
It's real great to know that I can get and set all the fields. Thanks previous programmer.
- AmpsterMan 7y agoThis is one of those paradigms that I don't understand in Java. It's the most trivial of trivial encapsulations.
- Izkata 7y agoIt is (was?) the primary way to maintain binary compatibility between versions of class files, where switching an attribute to a method (if logic such as verification needed to be added in a future version) would break that compatibility.
- mthoms 7y agoSetters I get (see what I did there?). It's the superfluous getters that simply return the values I'll never understand.
- Izkata 7y agoSee my cousin comment - it maintains compatibility when changes are internal to the class. For example, if a field was switched from concrete to derived, you'd have to switch the attribute to a getter, which would break compatibility with the previous version.