Re:Verb-Noun vs. Noun-Verb
by delusional on Wednesday October 16, 2019 @05:43PM
(#21276179)
It's real great to know that I can get and set all the fields. Thanks previous programmer.
[ Parent
| on HN ]
Re:Verb-Noun vs. Noun-Verb
by AmpsterMan on Wednesday October 16, 2019 @09:10PM
(#21277995)
This is one of those paradigms that I don't understand in Java. It's the most trivial of trivial encapsulations.
It 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.
Setters I get (see what I did there?). It's the superfluous getters that simply return the values I'll never understand.
See 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.