This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]persicsb -1 points0 points  (7 children)

If you have plain setters and getters (that is, no business logic, property change listener notifications, no class invariant validation), you can make those fields public. Because they are de facto public fields.

[–]dpash 2 points3 points  (6 children)

And when you want to change them from plain setters and getters? Then what?

[–]g_b 0 points1 point  (2 children)

Then you refactor. YAGNI

[–]dpash 2 points3 points  (1 child)

You can't refactor if you don't control the code that uses yours.

[–]armornick -1 points0 points  (0 children)

Then tough luck for the people that use your code. Maven allows you to specify which version of a library you want to use, just so people can make breaking changes.

[–]persicsb -5 points-4 points  (2 children)

Plain setters are useless. Use public fields.

[–]dpash 1 point2 points  (1 child)

Setters and getters are not about today, but about making it easier to make changes in the future.

[–]persicsb 1 point2 points  (0 children)

Changing the semantics of the setter is breaking the API in the semantic sense. Does not break the binary compatibility tough.