I still can't figure it out. Why do people still use auto-generated Getters and Setters instead of just making the field public? What is the advantage of using Beans these days? I've never run into a situation where I wanted my getter/setter to do something other than return/set the value.
Comments
I still can't figure it out. Why do people still use auto-generated Getters and Setters instead of just making the field public? What is the advantage of using Beans these days? I've never run into a situation where I wanted my getter/setter to do something other than return/set the value.
Mostly just convention, but it's also a more flexible pattern. A public instance variable cannot have public reads, but private writes for instance.
There is also the case of derived properties. e.g.
LocalDateTime ranAt
LocalDateTime finishedAt
getRuntime() { ... }