Composition instead of inheritance

Dan Stromberg drsalists at gmail.com
Thu Apr 28 23:58:57 EDT 2011


On Thu, Apr 28, 2011 at 3:35 PM, Carl Banks <pavlovevidence at gmail.com> wrote:
> On Thursday, April 28, 2011 10:15:02 AM UTC-7, Ethan Furman wrote:
>> For anybody interested in composition instead of multiple inheritance, I
>> have posted this recipe on ActiveState (for python 2.6/7, not 3.x):
>>
>> http://code.activestate.com/recipes/577658-composition-of-classes-instead-of-multiple-inherit/
>>
>> Comments welcome!
>
> That's not what we mean by composition.  Composition is when one object calls upon another object that it owns to implement some of its behavior.  Often used to model a part/whole relationship, hence the name.

It's a pretty old idea, that seems to be getting revived in a big way
all of a sudden.  Perhaps the Java people just rediscovered it?

In a Software Engineering class using Ada, the teacher called it
"Structural Inclusion", and of course it was an important concept in
Ada, because Ada had no inheritance.  This was in 1989-1990.



More information about the Python-list mailing list