Composition instead of inheritance

Ben Finney ben+python at benfinney.id.au
Fri Apr 29 00:14:36 EDT 2011


Dan Stromberg <drsalists at gmail.com> writes:

> On Thu, Apr 28, 2011 at 3:35 PM, Carl Banks <pavlovevidence at gmail.com> wrote:
> > 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?

I think it's more that people keep re-discovering how irredeemably messy
multiple inheritance is, and finding that object composition is better
in most cases :-)

-- 
 \      “There's a fine line between fishing and standing on the shore |
  `\                            looking like an idiot.” —Steven Wright |
_o__)                                                                  |
Ben Finney



More information about the Python-list mailing list