I hate getters and setters in java. Half of my code is filled with them. They are pointless boilerplate code that says nearly nothing. 99.9% (I made that number up, but it sounds reasonable) percent of the cases they don't have any additional code in them.
And it is really hard to see whether a variable is read-only/read-write/write-only. You have to find the getters/setters to see that.
I have a notation where I put all the modifiers at the end of the class and separate them with a page of whitespace.
I don't like the C# solution - it's not really shorter, only binds the getter and setter together.
I have a proposition: use annotations:
@Getter @Setter private boolean subscribedForEmailNotification; |
And one wants to write extra code, one should be able to use the old notation. The compiler will check for collisions.
I don't see any reason why this cannot become the next syntactic sugar in java where one saves a bunch of useless code-writing.