|Just another Perl shrine|
How to sub class-esby exilepanda (Pilgrim)
|on May 15, 2020 at 02:54 UTC||Need Help??|
exilepanda has asked for the wisdom of the Perl Monks concerning the following question:
For example, I have Robo class, which subclass from Robo::Arm Robo::Head Robo::Feet at once ( and each has it's own new() constructor ).
After lot of readings, I learned I can use Exporter and then push @ISA, or use base, or parent to obtain methods from other class(modules).
However, if a method is not solely depends on themselves, I mean, the being called method require attributes defined in the class's own constructor to work properly, the tricks of above will not work. The result is that I can access the method, but the method won't work properly.
Is that any trick that you can kick on the constructor ahead, and then calling those parent methods with correct object reference? Thank you very much for any clue.
Update: Thank you everyone that point out and I am agree that it is not an is-a scenario, but has-a, which is very likely what I am asking, but I have to point out that I do not have enough time to learn Moose at this moment.
Though, here's some code I can demonstrate.
Now, look at the walk from Feet, that's what I mean, I can access the method, but the method won't run as expected. I expect it won't walk if the init value was considered. So, I have a very clumsy work around
And that's what I am trying to ask a better way to do