anithri has asked for the wisdom of the Perl Monks concerning the following question:

I have a CGI::Application based module that is rapidly becoming unwieldy in it's size. I broke the modules subs into various subclasses. and then used:

package NursingOptions; use base qw/NursingOptions::Nurse, NursingOptions::Misc, NursingOption +s::Certifications/;

I assumed that the base class would simply inherit the subs of the various modules and I could go on using the base class as I had before.

Hoever, I'm getting errors with that method.

So.
Even if it's only for development purposes, What is the best way to break up a large module into smaller ones?

Replies are listed 'Best First'.
Re: Breaking up Large Modules.
by dragonchild (Archbishop) on Apr 11, 2004 at 03:57 UTC
    What errors are you getting? That could be helpful.

    Personally, I think you went about things the wrong way. Normally, one doesn't specialize, then shoehorn them back into the general case. Remember - you can use more than one .cgi in your "application". CGI::Application is really misnamed. It should be called CGI::ApplicationComponent. My current CGI app is actually made up of

    • main.cgi - login, logout, homepage, and the like
    • help.cgi - all help functionality, including FAQ and the like
    • search.cgi - all searching functionality (delegates to a generic searcher which everyone can use)
    • reports.cgi - all reports (which other areas delegate to as well)
    • messaging.cgi - one section of the application is about sending and receiving messages

    That's all in one web application. Each of them has their own class that inherits (indirectly) from CGI::Application. One C::A developer told me that if any of his C::A classes has more than 8-12 runmodes, he has to find a reason not to refactor it into more than one C::A class, with its own .cgi wrapper.

    ------
    We are the carpenters and bricklayers of the Information Age.

    Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

Re: Breaking up Large Modules.
by jeffa (Bishop) on Apr 11, 2004 at 14:46 UTC

    qw does not require you to add commas yourself. Try this instead:

    use base qw/NursingOptions::Nurse NursingOptions::Misc NursingOptions: +:Certifications/;
    Unless, of course, you really do have a package named NursingOptions/Nurse,.pm ...

    While this might fix your error, do heed dragonchild's advice. Of course, sometimes starting over and doing it "the right way" just isn't practical. In your case, i hope it is. :)

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)