News for hackers. Stuff that matters.
Re:Data Classes for Java by geophile on Wednesday November 01, 2017 @08:49PM (#15606908)
I think getters/setters are an abomination resulting from a sensible OO idea taken too far.

Having private fields and public methods has benefits that are so obvious that I won't belabor the point. Sometimes -- maybe even often -- you really do want to get and set some fields, so then you have getters and setters. But applying this pattern blindly, to all fields, is insane and, as many people on this thread have noted, defeat the point of private fields and public methods. Just make the fields public, because that's how much protection you have anyway. (Adding code around the getting and setting is, of course, easier with methods already in place.)

I think this trend really got started with Java Beans, in which getters/setters were required (unless you wanted to write yet more code to nominate other methods as the getters and setters). And then the stupidity set in. Well why wouldn't you want your object to be a bean? Beans are good! Be a bean.

I believe that things like corporate coding standards then kicked in and made this nonsense unavoidable.

Re:Data Classes for Java by platz on Thursday November 02, 2017 @12:21AM (#15607811)
just use a struct for plain data