skazat has asked for the wisdom of the Perl Monks concerning the following question:
Hello All,
This is sort of a funky question, so I'll try to explain the best I can.
I have a fairly complex web-based program, I'd like to allow people who use the program to 'roll their own' parts of the program. See? no makey sense, let me explain with an example:
Say I have the common form handler; a user submits a form, the form info gets mailed to whomever; the user gets a thank you message from the scrpt.
Now, say, instead of having the script generate a thank you page, I want it to redirect to a different page.. BUT! I don't want to implicitly add this feature into the script, I just want the script to have hooks to a uniquely specified function or something. That way, anyone with enough know-how can easily make a new chunk oh code that the main part of the program can call, but I don't want this new chunk to live inside the main program, it should be on it's own.
Am I making sense? I'm not sure. An idea on the top of my head is to have a variable that controls if the program should use its built in way of doing things. Something like:
if($roll_your_own == 1){ system('a_different_script.pl'); }else{ go_at_it_yourself(); }
In this example, I'm calling an outside script to handle the job. Right away, this doesn't seem to be the best thing to do; since I'm not sure exactly the outside script will retreive all the arguments, and there's always security concerns with system();
Would a better way be to have a module specifically designed to all you to put your own code in? something like:
if($roll_your_own == 1){ require RollYourOwn RollYourOwn::rollit($do_this) }else{ go_at_it_yourself(); }
I know this must be something that other people have come across in big scripts; they want to have the ability to add the functionalitly, but not have that functionality in the distribution, since the functionality could be so local it wouldn't make sense in other uses of the program.
-justin simoni
!skazat!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Allowing the over riding of a program's design
by chromatic (Archbishop) on Feb 06, 2002 at 21:52 UTC | |
|
Re: Allowing the over riding of a program's design
by Spudnuts (Pilgrim) on Feb 06, 2002 at 23:59 UTC | |
|
Re: Allowing the over riding of a program's design
by trs80 (Priest) on Feb 07, 2002 at 06:46 UTC | |
by skazat (Chaplain) on Feb 07, 2002 at 19:16 UTC |