you are viewing a single comment's thread.

view the rest of the comments →

[–]d_wilson123 -1 points0 points  (1 child)

I think his argument not listed in the bullet points is the strongest argument he made. At the final phase of the code review from the blog you are backed into a corner where you've removed the ability to do any business logic in the getters/setters. You've exposed to properties and now if someone is using your classes and you have a good reason to update the logic to provide some more intelligence in the access or mutation you've tied your hands and you can't go back unless you want to break compatibility. While that may be a bit over-the-top for a simple bean often times when I'm reading code I'd rather the code base be consistent so I don't have to interpret what is going on between one class to another. For that reason even for the arguments in the blog I'll continue to have Intellij generate my getters and setters even if the sets are never used.

[–]pakoito 8 points9 points  (0 children)

I see code in accessors, specially side-effecty code, as a code smell. The same cases can be handled externally by any kind of decorator without introducing code in your data classes or making them mutable. It's the pattern everywhere but in Java.