Am I missing something regarding how the Property class does not violate this rule?
He "breaks" the rule. However, the rule is not universal, because the document you are quoting is making great efforts to try to explain from the very beginning. This document describes "microoptimization." They, as stated in the document, "will almost never do or violate your software." Rather, these are things that you might want to optimize in certain places that need it.
You do not need to avoid internal getters and setters unless they cause special performance problems . You can usually determine this using Traceview and seeing a lot of time spent in getters and setters.
So, for example, in a narrow loop over a large data set, getters and setters should probably be avoided. Outside of scenarios like this, using getters and setters is unlikely to cause you any kind of material pain or user. Again, let tools like Traceview be your guide.
Now, oddly enough, some of the intended uses of the Property (such as ObjectAnimator ) may seem more demanding on micro-optimization than your average code. I think you just need to see if the animation works as smoothly as you want. I have not used ObjectAnimator directly yet, not to mention the ICS Property , so I can only hope that all of this will work well.
source share