Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
I know that CGI::Application::Dispatch could do something like what I'm thinking about, but I'm not sure it's the right tool for the job.

I'm (considering) re-architecting a client application that runs under mod_perl. It's a large refactor, basically one from the ground up. There are many little and not-so-little problems with it, like blessing objects into the wrong namespaces, excessive argument and data passing, cookies set via javascript that get lost between requests .... I'll also be using more of the mod_perl hooks than vanilla CGI, etc. I'm trying to trim this thing down and rebuild for 'testability' with as little pain as possible.

I pulled out my Gang of Four book to see if there are any existing patterns to help solve the problem. I'm not 100% sure which pattern they define would be the right one, nor am I 100% convinced that I can't/ shouldn't use CGI::Application::Dispatch.

The application now isn't really 'run-modes', but separate classes that are instantiated to do specific things: a type of report, lookup table management, etc. I could translate these into run-modes at the risk of having to rewrite more. (The app currently uses $ENV{REQUESTED_PAGE} to determine the URL, look that page up in a templates table, then load the appropriate module (and template, if overridden) then perform the needed actions.)

I could feasibly build the run_modes structure needed by CGI::App::Dispatch dynamically (at least during development) ... but I'm not convinced it's the 'right' thing to do.

The task here seems simple enough: find a clean way to transform a URL into an instantiated object ... but a look through CPAN pretty much confirmed that there isn't much out there, unless it's a different name than I'm thinking.

It looks like a "Factory" pattern (from the GOF book) is the beginning of the right way to go, but are there existing modules that have already done this, or should I roll my own?


In reply to designing a dispatch class by geektron

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others studying the Monastery: (5)
    As of 2014-10-24 23:38 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      For retirement, I am banking on:










      Results (138 votes), past polls