News for hackers. Stuff that matters.
Re:Java memes which refuse to die by nl on Monday August 27, 2012 @11:28AM (#4439251)
TL;DR: Fields are fields, methods are methods, auto-generating getters/setters blurs the line in unhelpful ways.

That's not really true in Java. The getter/setter pattern is baked into a lot of the standard Java libraries.

For example, Javabeans are:

a Java Object that is serializable, has a 0-argument constructor, and allows access to properties using getter and setter methods.[1]

Things like JPA, Jersey, Guice etc all rely on the Javabeans convention.

Yes, Java should have real properties like Object Pascal & C# does, but it doesn't, and getters & setters are harmless to anything except aesthetic sensibilities.

TL;DR: Getters & setters are a useful convention that allow many things that are not possible with public fields.

[1] http://en.wikipedia.org/wiki/JavaBeans

There are no comments on this comment yet.