[Tutor] inheritance vs aggregation in Python
Erik Price
erikprice@mac.com
Tue, 27 Aug 2002 13:53:02 -0400
My understanding of inheritance and aggregation are pretty limited. I
have a question about them (in Python).
From what I understand, the primary benefit of inheritance (over
aggregation) is that the object is of the same type as the ancestor
object it is inheriting from. This is important in Java and presumably
in other strongly typed languages.
However, aggregation of objects seems (to me) to be more flexible than
inheriting from objects, since you don't limit yourself to just that
type.
So, then, in Python, typing isn't strongly enforced -- so then what is
the advantage of inheritance vs simply aggregating an object that you
might need? (Other than any performance-related reasons, I'm asking
this question in a theoretical rather than practical sense.)
Perhaps I've missed some important point, if so then dope slap me and
tell me what it is.
Thanks,
Erik
PS: (I swear I've asked this question before, so I probably deserve a
dope slap anyway for having forgotten.)