Subclassing vs. Composing [was: Having brains again after being headless?]

Tim Olson tim at io.com
Sat Dec 14 15:12:58 UTC 2002


Marcel Weiher <marcel at metaobject.com> wrote:
| Well....there is the interp.m translation of the VM to Objective-C, 
| which has Interpreter as a subclass of ObjectMemory, just like the 
| Squeak source.

I can't remember if this was answered previously in this thread, but
what are the reasons for having Interpreter be a subclass of
ObjectMemory, as opposed to having an instance variable which is an
ObjectMemory?

Personally, I use subclassing only when the subclass is clearly the same
kind of thing as the parent class (with some slight behavior changes),
and composition for everything else.  But I suppose I may be missing out
on some benefits of subclassing.

	-- Tim Olson



More information about the Squeak-dev mailing list