Variable inheritance
Oleg Broytmann
phd at phd.fep.ru
Tue May 22 04:32:30 EDT 2001
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.
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.
More information about the Python-list
mailing list