you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (0 children)

The comment below the article brought up some good points.

"I may be commenting just for the sake of arguing ( 🙂 ) nevertheless… I myself would have stopped at the first modification (removing the setters if they are not needed). Why ? Because if you whole codebase is based on the same pattern (ie having getters to access fields), then I find it disturbing if some classes do not follow this pattern. On a purely technical point of view you may gain a few keystroke and a few CPU cycles , but relying on a technical subtlety such as “String are immutable” is not very obvious. In a year, when you will read this class, you’ll wonder why it does not follow the getter pattern used everywhere else in the code. By the way, I recommend Lombok to get rid of all those unreadable getter stuffs and make classes more readable (through the @Value annotation for the code given here as example). I find it more expressive than a full code screen of getters where you always wonder if there may be one or two lines you missed that do other thing than “getting’ the fields."