in reply to Re^2: Help me understand inheritance please!
in thread Help me understand inheritance please!
my 'toolchest' of things be put into a 'normal' module and be imported into the OO module
Your toolchest doesn't necessarily have to be a procedural ("normal") module, it too can be object oriented. diotalevi is only suggesting that the relationship between your toolchest module and your application module doesn't appear to be one where inheritance is appropriate.
Inheritance is for when one thing is another thing, where as delegation is when one thing has another thing. These are commonly refered to as is-a and has-a relationships. This is why inheritance in Perl is done through the @ISA array. Delegation in Perl can be accomplished simply by storing one object as an attribute in another object, and calling the first object's methods as appropriate.
To further reinforce the point, consider describing your situation in these terms. Does it make more sense to say "my application is a toolbox" or "my application has a toolbox"? Compare to a frequent example where inheritance is used: "this cat is a mammal" vs "this cat has a mammal." That should help you decide which is appropriate.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Help me understand inheritance please!
by Anonymous Monk on Nov 05, 2004 at 03:40 UTC | |
by BrowserUk (Patriarch) on Nov 05, 2004 at 04:16 UTC | |
by dragonchild (Archbishop) on Nov 05, 2004 at 03:49 UTC |