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

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


On 25-Nov-2008, at 10:45 PM, Igor Stasenko wrote:
>
> My understanding of inheritance is different, in short:
> A subclass of particular class is a _specialization_ of base class,
> not  _expansion_.

Well when you're defining the behaviour of objects in an OO system  
there's not really any difference between "specialization" and  
"expansion" -- the subclass is _adding_ changes to the definitions  
given in the superclass.  Perhaps the changes will over-ride a  
behaviour in the superclass, or modify it in some way, but  
fundamentally a subclass is always adding something to the superclass  
in order to create the new subclass it defines.

Or to paraphrase the Blue Book, allowing intersection in class  
membership is the basic mechanism used to allow code sharing between  
class descriptions.  Smalltalk-80 of course doesn't allow multiple  
inheritance, just plain subclassing.

> If you look from a user's point of view (outside a class), you could
> only send a messages to it. So, for you, as for user its not relevant
> where an object holds its state - you only interested in its
> behavior/interface.

You don't send messages to a class -- you send messages to objects  
which are derived from a class, i.e. which follow the behaviours  
defined by the class.

> As for subclass - a subclass interested in inheriting same interface
> as base class. Inheriting a state information having a little
> importance, its just an implementation detail for outside user of
> class, because anyways he unable to operate with this state directly.

Classes don't have state -- objects have state.  An object which has  
been derived from a subclass gains definitions about its state from  
_all_ of the classes in the class hierarchy which the subclass belongs  
to.

At least that's how I understand things in the Smalltalk way of  
defining classes and instantiating objects.

-- 
					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/4b0afd81/PGP.pgp


More information about the Squeak-dev mailing list