3 ms·
Java is the only place where (non-automatic/non-syntax-sugared) getters and setters are though as important and valuable Only goes to confirm my view of them t
by raverbashing 3y ago
Java is the only place where (non-automatic/non-syntax-sugared) getters and setters are though as important and valuable
Only goes to confirm my view of them that the language is deficient
- hubraumhugo 3y agoRecord types solved this in JDK 14
- CraigJPerry 3y agoI don’t think it’s accurate to label that as a language problem. That is very squarely a people problem. It’s not as bad today - many Java juniors don’t have the “bean” affliction burned into their brains so they don’t object to public fields on data carriers (today you’d just use a record) but even the bean generation (mostly people my age) can usually be won over these days by negotiating with them on cases where getters/setters can be eliminated (e.g. start with value objects, then suggest maybe DTOs then you can go for the kill - why do we need the stupid Java bean convention?)
- Slartie 3y agoModern Java projects either use records, org.immutables or Lombok. Manual getter/setter creation is the exception nowadays.
- srvaroa 3y agoI don’t find they are valued like that. IME most devs who use them perceive them as annoying boilerplate. Proof being how Lombok or Records are generally well received among the younger gen. The problem on this topic is that they cargo cult getters/setters by inertia, usually because more experienced engs pass it on as good practice. It’s not an inherent problem to the language.