News for hackers. Stuff that matters.
Re:Java 1.0 Turns 25 by vbezhenar on Saturday January 23, 2021 @11:34AM (#25883560)
You will need getters/setters for some fields. So your code will look weird:

    p.x = p.getY() + p.z;
    p.setY(p.x + p.z);
It's better to use more universal approach, so your code will look unified.

Another thing why getters/setters are preferable is because when you need to replace field with computed value, you would need to replace all your code.

Proper approach would be to use properties which are available for every language but Java. They invented records, which somewhat fill that niche.

Re:Java 1.0 Turns 25 by eweise on Saturday January 23, 2021 @07:09PM (#25887422)
I've used Java for over 20 years. Not once have I ever replaced an attribute with a computed value.

Also p.x = p.y + p.z is much easier read.

Another drawback of getters and setters is that you end up not looking at that code because you assume you know what it does, so you can miss when someone puts logic into a setter or getter

Re:Java 1.0 Turns 25 by augustk on Saturday January 23, 2021 @03:51PM (#25885936)
I don't like the idea of having a verb in the name of a pure function. I think it reads better to simply name the function after the result it returns.