Here’s an article that bears extensive further consideration: Why getter and setter methods are evil, by Allen Holub. I confess that I’m a huge user of getter and setter methods, for any number of reasons. In my own code, I use getters and setters exclusively when accessing member variables in the classes in which they are defined to make it completely obvious that I’m not dealing with a local variable or an argument. That problem is just as easily addressed, though, by adopting a naming convention for member variables. I also commonly find myself using systems that are heavily dependent on accessor methods — both Struts and Hibernate are heavy users of accessors. That said, the principles in the article could still be applied by ignoring the accessors where appropriate and using the objects in the manner that he describes. What I wish is that the article came with some sample code that illustrated the abstract points discussed within. Maybe Holub’s forthcoming book will include such code.
Holub’s other article (on the extends keyword) is interesting as well. In fact, in reading the two together you can see how you might design programs more flexibly by leaving all of the accessors out of your interfaces but putting them into your implementation classes, and then being disciplined about using the interfaces as much as possible.