Re: Tool for inlining useless getter/setter call
Disregard that advice. Use of accessors and mutators is a best
Patrick May wrote:
No, it's a bad practice. Wherever possible, objects should be
immutable. Where not possible, follow the rule of "tell, don't ask."
If you have classes that poke around in the internals of other classes
in order to accomplish their goals, you need to repartition your
Widespread use of accessors and mutators is the sign of a poorly
I completely disagree. Let the readers choose for themselves.
Your philosophy just threw out all JavaBeans, all bean property editors, all
IDEs, all of JPA, JSTL, JSF, in fact, just about every framework written for
Java. Quite frankly, I think calling accessors and mutators "sign[s] of a
poorly designed system" is completely whacked. It is ingrained in Java
culture to use them.
I still aver that they are a best practice. They allow, for example, for the
actual attribute members to be private, for all kinds of checking and
invariant enforcement, control of exceptions, integration with and
proliferation of useful frameworks, and are manifestly responsible for the
great growth of all kinds of useful APIs. They add safety, enforce the
fundamental values of encapsulation and non-dependency, and author after
author touts them as best practices. I offer those facts in evidence.