News for hackers. Stuff that matters.
Re:Everything about Java 8 by jiggy2011 on Wednesday March 27, 2013 @03:56PM (#5451604)
I think it's partly a defensive tactic to stop others playing fast and loose with your object state.

I used to write classes and then add fields and auto generate getters/setters.

Now I don't, I just make all the state private and if I find myself wanting a getter/setter I ask myself why.

Too much use of getters/setters is just reinventing the problem that private state was meant to avoid.

So for example rather than:

if(email.getState() == EmailState.SENT) {

I have:

if(email.wasItSent()) {

Re:Everything about Java 8 by edwinnathaniel on Thursday March 28, 2013 @01:06PM (#5456108)
What if a 3rd-party API only works on Beans? (i.e. doesn't support private properties).