in reply to One Big Script v. Several Small Scripts

Others have commented on the Perl side of this, and the advantages to code maintenance of one approach or the other, but I'd like to add another consideration: the web side. It's the sort of theoretically minor thing that could easily be overlooked, but depending on your situation it could be significant.

If you do the whole thing as one big script, all the parts of it will have the same URI; if you split it up into multiple scripts, they won't. (Another poster spoke of splitting out various modules and having the main script load those it needs; that hybrid approach could be made to fall, from the web's perspective, into the one-big-script category. Conversely, if you use GET, one script may have different URIs.)

So you want to ask yourself, does it matter whether the various pieces have the same URI or not? If two pages have the same URI, it has a lot of effects. The browser will treat them the same for bookmarking purposes. Do you want to be able to bookmark the "add comment" page, for convenience, or do you want the user to have to go through the main page every time? Any forms they contain will probably get treated as the same page of forms by browsers that have autofill features. Is that good, or bad, in your circumstances? There may also be more subtle effects; a page that has the same URI as an earlier page may force the earlier page out of a browser's cache, for example. These sorts of things are IMO well worth considering when you decide whether to put various parts of your site in the same script or separate them.

 --jonadab

Replies are listed 'Best First'.
Re: Re: One Big Script v. Several Small Scripts
by Cody Pendant (Prior) on Jan 29, 2003 at 03:45 UTC
    >If two pages have the same URI, it has a lot of effects. The browser will treat them the same for bookmarking purposes.

    Actually, I tend to bookmark app.cgi?mode=edit seperately to app.cgi?mode=list and use them that way. But I'm talking about applications I write for myself alone mostly, so yes, you're right that the user-perspective is altered by the single-script method.

    Thank you all very much for your input. I feel vindicated, and also educated.
    --

    “Every bit of code is either naturally related to the problem at hand, or else it's an accidental side effect of the fact that you happened to solve the problem using a digital computer.”
    M-J D
Re: Re: One Big Script v. Several Small Scripts
by abell (Chaplain) on Jan 29, 2003 at 13:43 UTC

    I suggest considering tools like the Apache module mod_rewrite to allow an indipendence of URIs from implementation choices. URIs should not change if you switch from a single script to a multiple script approach and they should be more related to contents than to application paths.

    Thus, a preliminary step should take care of converting http://www.mydomain.org/posts/insert.html to either app.cgi?mode=edit or edit.cgi.

    Cheers

    Antonio

    The stupider the astronaut, the easier it is to win the trip to Vega - A. Tucket