Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^4: CGI::Application, inheritance trees, and 'the right way'

by drewbie (Chaplain)
on Nov 02, 2004 at 18:37 UTC ( [id://404706]=note: print w/replies, xml ) Need Help??


in reply to Re^3: CGI::Application, inheritance trees, and 'the right way'
in thread CGI::Application, inheritance trees, and 'the right way'

Say I have 3 main pieces of code for a shopping cart - user management, product management, and order management. In this case, I'd have one CGI::Application module that works on the run mode "action" variable. So we'd have three run-modes: user, product, and order.

My "Main" CGI::Application would be using the "action" variable to decide the run-mode. It's only choices would be user, product, and order. Depending on which of these it is, it would instantiate another CGI::Application module of that type. So if the main run-mode is "user," it would do something like:

my $user_app = new UserApp(...);

You might want to take a look at CGI::Application::Dispatch. It does the same sort of thing in that it uses the URL to figure out the application & runmode. So the url "/app/product/delete?product_id=1234" would map to the YourPrefix::Product CGI::Application class (the prefix is configurable) and set the runmode for said application to "delete". It seems like the same as idea as your code above, but with less code you have to write. :-)
  • Comment on Re^4: CGI::Application, inheritance trees, and 'the right way'

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://404706]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-04-19 17:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found