3 ms·
I'm from the ancient years of Java, surely this must have started at some point ? Do you get getters and setters ? I left Java around version 5.
by stuaxo 8mo ago
I'm from the ancient years of Java, surely this must have started at some point ?
Do you get getters and setters ?
I left Java around version 5.
- leapingdog 8mo agoRecords [0] are a modern form of data transfer object. They are immutable though. [0] https://docs.oracle.com/en/java/javase/17/language/records.html https://docs.oracle.com/en/java/javase/17/language/records.h...
- jghn 8mo agoThe more modern take is to not bother with getters & setters for most things. People were cargo-cutting getters/setters on every variable without thinking about the implications. First off, there's the question of if most things should even *allow* updates or just be immutable. Second, what's the discernable difference between `public final int foo` and `private final foo` w/ `public int getFoo()`. Nothing really. The claim was always "but what if you want to update `foo` to be something more complex? The pain that these advocates always suggested never really wound up being much of a real world problem.
- leapingdog 8mo agoAnything relying on beans for (de)serialization via reflection (XML; JSON) were the big incentive in the J2EE space if I recall correctly.
- jghn 8mo agoYes. And I believe it kept going with Spring. But those were mistakes imposed by frameworks. Not a necessity for good language usage.