I think philcrow has a good idea above. Basically you want to treat these files as if they are CGI::Application plugins. However, this solution is not without it's issues (exported methods conflicting, or overriding inherited methods, etc etc etc).

As for the "is this good OO", the answer IMO is yes (kind of). What you are doing here is not all that different from what Perl 6 Roles try to do, which is to break down classes one step further. A role is not a class, but instead a collection of reusable methods which can be "injected" into a class's namespace.

At $work, we have been experimenting with using Moose and more specifically Moose::Role for this type of problem. We have a base CGI::Application subclass which we all our applications inherit from, then we have a set of common roles which we can then add to our application. The roles include things like configuration file management, DBIx::Class schema setup and management, request logging and a number of other items which are useful in most (but not all) applications.

And if you don't want to use Moose, you could also look into the other Role modules on CPAN. I would recommend Perl6::Roles or Class::Trait, with Class::Trait being the more "full-featured" of the two.

-stvn

In reply to Re: Class Inheritance Abuse. Best way to fix it? by stvn
in thread Class Inheritance Abuse. Best way to fix it? by BMaximus

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.