Hi

Regarding your update about  $self->{foo} = $Obj::foo_cache{$id}; not working: that's because you've declared your 'cache' variables as 'my' variables, but refered to them as package variables. If you change the declaration to 'our' instead of my, it should work, I think...

About your design question, I'm no OO guru but using inheritance where it doesn't make sense I'm pretty sure is one the the things OO gurus go on about a lot. For reasons including:

For better explanations, consult an OO guru ;-)

For a more convenient way to dispatch methods off to a 'delegate' class, I suggest looking at a framework on top of Perl's bare object system. The most popular at the moment seems to be Moose, but I've not got round to using it so can't say for sure if it's best...

FalseVinylShrub

Disclaimer: Please review and test code, and use at your own risk... If I answer a question, I would like to hear if and how you solved your problem.


In reply to Re: Designing an OO program with multiple inherited classes by FalseVinylShrub
in thread Designing an OO program with multiple inherited classes by punkish

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.