Well, I think that I just pulled stuff out from a bunch of sources.

Then, the rest of my post was extrapolation from there, plus a little bit of trial-and-error.

Other's code: check out the history of CGI::Application. When I first started using it, it handled the two cases (code ref and function name) separately. It now handles them identically (for a fairly significant improvement in speed... at least for that portion of the code).

If you want to limit your users to only using function calls, that's fine. Make it look like a function call. Personally, with this syntax, I see little reason to limit the users like that, especially if you're passing $self in anyway. It allows incredible flexibility (callback or inheritance, or both!) with no cost to the base class. All incredibly different from other OO languages. It allows polymorphic polymorphism - you can change the way that you override something completely dynamically.

One of the reasons why perl doesn't have access modifiers such as public, private, and protected, is because it's recognised that they often get in the way of getting the job done: what was envisioned by the original designer has nothing to do with what you want to do with it. In the same way, design for flexibility - although you may not see yourself needing it now, the next person to come along may see it being incredibly handy to solve that new problem, and will bless your genius for developing that flexibility ;-)


In reply to Re^5: Seeking advice for OO-related strategy by Tanktalus
in thread Seeking advice for OO-related strategy by blazar

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.