Hacker News new | ask | show | jobs
by reginaldjcooper 4572 days ago
> When I started with Java, it seemed appropriate to put hundreds of getter / setter methods. Is there much advantage to that over allowing the variable to be accessed directly?

Oh my yes. As soon as you need more than one processor messing with an object they are invaluable. The only thing better is immutable objects.

It's also nice to have the object interface separate from object data if you want to change the object data representation without breaking everything (I don't know in general when you would do this, I just know I have done it before and getter/setters let me work faster to refactor).