Question about subclassing - version 2
Bruno Desthuilliers
bdesth.quelquechose at free.quelquepart.fr
Sat Sep 9 14:24:57 EDT 2006
Maric Michaud a écrit :
> Le vendredi 08 septembre 2006 10:15, Bruno Desthuilliers a écrit :
>
>>You
>>mentioned NotImplementedError, which is indeed the usual way to make
>>something "abstract" in Python.
>
>
> Hummm, some more thoughts about this.
>
> I can imagine class hierarchies where the presence of not implemented methods
> doesn't mean that the class is actually an abstract one.
I can imagine this too - as well as I can imagine the nightmarish
spaghetti code that could use this class hierarchie.
> Even if partial
> implementation is not a common scheme it can save you from writing a lot of
> classes.
A partial implementation should return default values, not raise (aka
NullObjectPattern). Well, IMHO at least.
(snip)
> And this can become a true spider net for more complicated cases. Obviously,
> in practice we will choose alternatives to inheritance (strategies,
> visitors, ...)
Composition/delegation...
> to work with such complex situations,
Indeed.
More information about the Python-list
mailing list