![]() |
|
Perl: the Markov chain saw | |
PerlMonks |
Re^3: object oriented Perl advice / constructor creation in child classby haj (Vicar) |
on Jul 11, 2018 at 09:43 UTC ( #1218296=note: print w/replies, xml ) | Need Help?? |
Sorry, but I don't see how Tie::Hash would help you here. In another reply you write that all your classes A to D already exist and have their own new methods, so Moo(se) inheritance (which makes Moose classes inherit from other Moose classes) isn't easily done either. As others have explained, Perl's method resolution with mro might help to some extent, but I doubt that it is worth the trouble. In any case you need to understand which of the methods you want to have available through the interface of C::C1 objects, especially with regard to their new methods. On whatever I've seen so far, I'd go for the delegation approach. The the existing classes don't have to be Moo(se) classes, and you explicitly implement the methods you want to make available through your C::C1 objects, and you can decide who should construct your A to D objects.
Maybe you want your users to read/write A to D? Here's an example for D: Someone using C::C1 would write like this:
Moo or Moose can help to make your C/C1.pm more readable, because they have keywords for method delegation, as I've shown in my previous example. But before going deeper, I'd like to understand how the interface of your C/C1.pm should look like.
In Section
Seekers of Perl Wisdom
|
|