Friday, March 31, 2006

Down with protected class variables?

I'm not sure.

Kasia writes in her blog entry:

If a variable is not final then it should be private. If you need to make it accessible to another class and there is no accessor then you're probably not doing something right.

While true, that making fields/attributes publicly available via an interface of sorts (not "Interface in the sense of an abstract class, but just in the sense of certain known methods), and not directly from a "friend" class/function or a derived sub-class.

But, unless the compiler is doing some inlining for you, then the performance hit on making those extra accessor calls, and the extra layer of indirection seems prohibative.

But, then perhaps I'm forgetting that computers are constantly evolving and these kind of pre-conceived bottlenecks aren't actually anything to worry about.

No comments: