geektron has asked for the wisdom of the Perl Monks concerning the following question:
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.
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?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: designing a dispatch class
by tlm (Prior) on Mar 30, 2005 at 23:20 UTC | |
by geektron (Curate) on Mar 30, 2005 at 23:29 UTC | |
by tlm (Prior) on Mar 30, 2005 at 23:35 UTC |