Carl Banks a écrit :
On Apr 22, 10:36 am, George Sakkis <[EMAIL PROTECTED]> wrote:
On Apr 22, 10:22 am, Carl Banks <[EMAIL PROTECTED]> wrote:

Java (for example) allows a class to share behavior with only one
other class, and that *severely* limits the opportunities to minimize
redundancy.
Not really; composition is usually a better way to share functionality
and reduce redundancy than inheritance.

I should have known this was coming.  I disagree: inheritance is a
much better way to share behavior.
>
(snip)
With composition you're burdening the user with having to learn the
shared relationships that ought to be implementation details of the
class.  E.g.,

obj.action_style.perform_action()
>
With inheritance, the user doesn't have to worry about these
relationships.

obj.perform_action()

(snip)
Unless you use composition + delegation (which is a PITA in Java and close to a no-brainer in Python). In which case this is mostly transparent to the user code.

Anyway, in Python, inheritence is kind of a special case of composition+delegation.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to