Fwd: Python Design Patterns - composition vs. inheritance

Matthieu Brucher matthieu.brucher at gmail.com
Thu Nov 15 17:38:51 EST 2007


Sorry for the double post

---------- Forwarded message ----------
From: Matthieu Brucher <matthieu.brucher at gmail.com>
Date: 15 nov. 2007 23:38
Subject: Re: Python Design Patterns - composition vs. inheritance
To: "snewman18 at gmail.com" <snewman18 at gmail.com>



2007/11/15, snewman18 at gmail.com <snewman18 at gmail.com>:
>
> In learning about design patterns, I've seen discussion about using
> inheritance when an object's relationship to another object is 'is-a'
> and composition when the relationship is 'has-a'.


Another way to express this is to say :
- inheritance when you want to reuse an interface
- compositon when you want to reuse the implementation
IIRC this is the approach of Bruce Eckel.

Matthieu
-- 
French PhD student
Website : http://miles.developpez.com/
Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92
LinkedIn : http://www.linkedin.com/in/matthieubrucher

-- 
French PhD student
Website : http://miles.developpez.com/
Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92
LinkedIn : http://www.linkedin.com/in/matthieubrucher
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20071115/e122c9b5/attachment.html>


More information about the Python-list mailing list