2008/11/12 Joe Strout <[EMAIL PROTECTED]>:

>> If you need to know that it walks like a duck, mates like a duck and
>> tastes like a duck when roasted, you probably want it to really /be/ a
>> duck and should go back to inheritance.
>
> I can't agree; there are times when inheritance just won't do, for example
> when you don't have control over the object creation, because they come from
> some factory method you can't change.  In that case you may need to make a
> wrapper instead of a subclass, but if you've faithfully implemented the
> interface of the original class, you should be able to use it wherever the
> original class could be used (within reason).

And then the original class definition changes -- new members added --
but the ones from the factory class don't change, and so are no longer
compliant with the the factory class (which doesn't support the new
"form_pun_relating_to_avoiding_a_high_hazard()" method) . Fine. If you
checked for all the members of the class that your code uses, it makes
no difference. ABCs give you a way of doing this, but in their absence
it's a long list of checks. If you /can/ use inheritance then it saves
having to do those checks.

-- 
Tim Rowe
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to