On 25-Nov-2008, at 7:57 PM, Igor Stasenko wrote:
I like the idea of hiding the state/storage specific details from eyes of subclasses. It makes irrelevant, in what format or where particular object holds its state. As long as you providing messages to access it, it could be anything.
So why not just get rid of instance variables completely? :-)
I think Ramon Leon hit the nail on the head. You're not supposed to try to protect anything in a class definition from any of its subclasses. Inheritance is a mechanism to _expand_ upon the definition of a class, not restrict it.
An instance of an object contains all of the components (instance variables, methods, etc.) of the class it belongs to as well as, by definition, all of the components from any (and all) class(es) it inherits from. That's the whole idea, as I understand it, underlying the concept of inheritance.
An object shouldn't have to use accessor methods to get at its own internal state, no matter where in the class hierarchy its state may be defined. "super" is only needed to get around explicit re- definitions done by the subclass.