Variable inheritance

Roman Suzi rnd at onego.ru
Tue May 22 04:48:21 EDT 2001


On Tue, 22 May 2001, Oleg Broytmann wrote:

> On Tue, 22 May 2001, Roman Suzi wrote:
> > I was always very irritated when somebody proposed something like
> >
> > class Line(Point):
> >   ...
> >
> > just because line could be made of two points.
> 
>    Of course. Now THIS is bad design. Line IS NOT a point, hence, no
> inheritance should occur. Line CONSISTS of two point, so
> 
> class Line:
>    def __init__(self, p1, p2):
>       self.p1 = p1
>       self.p2 = p2
> 
>    But grey mouse DOES NOT "contains" grey color. The mouse IS really grey
> thing, hence I used inheritance.

It could be _said_ of everything:

Thing IS HavingSomethingThing

instead of

Thing HAS Something

;-)

(Note, that the later is much shorter and clearer!)

So, your example doesn't make strong agrument.

I could agree that though, that

class Janus(Face1, Face2)

;-)

>    This is difference between "thing IS a thing of the class" and "thing
> CONTAINS things".
> 
> Oleg.
> ----
>      Oleg Broytmann            http://phd.pp.ru/            phd at phd.pp.ru
>            Programmers don't die, they just GOSUB without RETURN.
> 
> 

Sincerely yours, Roman A.Suzi
-- 
 - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru -
 





More information about the Python-list mailing list