[squeak-dev] Re: Instance variable access in superclasses.

Greg A. Woods; Planix, Inc. woods at planix.ca
Wed Nov 26 03:19:36 UTC 2008

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.

					Greg A. Woods; Planix, Inc.
					<woods at planix.ca>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20081125/1a0ae2ae/PGP.pgp

More information about the Squeak-dev mailing list