Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

One Big script or many little ones?

by BigJoe (Curate)
on Jun 15, 2000 at 05:42 UTC ( #18217=perlquestion: print w/replies, xml ) Need Help??

BigJoe has asked for the wisdom of the Perl Monks concerning the following question:

I am very curious. Currently I am working on a CGI and I find myself adding different things into this script. Like I have 2 frames that are written from the same script and the buttons on them access the same script. But for a while I had like 5 scripts maybe 10 lines each doing each function.

I was curious about others prefrences with this and maybe some reasoning behind each method.

  • I like the small scripts that only do one task because they are easy to maintain.
  • But I also like one large script that does everything because it is easy to move from server to server.


What do you guys think?

--Big Joe

Replies are listed 'Best First'.
RE: One Big script or many little ones?
by plaid (Chaplain) on Jun 15, 2000 at 07:03 UTC
    In general, I prefer to put things in the same file unless they are going to be reusable, in which case it's better to stick them in a module. Instead of splitting things into different scripts for maintainability, try taking the parts you would put in a different file and instead just stick them in different subs. I find it pretty easy to navigate around code that's logically split up and separates the big chunks into functions that can be pored over if needed, but can just as easily be skipped without any loss of continuity.
RE: One Big script or many little ones?
by Apterigo (Scribe) on Jun 15, 2000 at 06:43 UTC
    I guess it really depends on what you need. If you need it to be easy to maintain, you'd better go with smaller scripts, but if your going to have to move it from server to server, your probably better off going with one big script. I think it really depends on the situation, and you as the programmer need to determine what is best for that situation.

    My thoughts,
    Apterigo
RE: One Big script or many little ones?
by Anonymous Monk on Jun 15, 2000 at 17:02 UTC
    I have been wondering about the same thing recently.
    I have decided to go with big scripts on my website. You can use hidden form variables to tell your script which form is calling your CGI so you will know which sub(s) to call.

    I'm still working on my site, but I play to use CGI.pm and have one script for generating my pages and one script for parsing form data.

    Hope this helps,

    Rad (newbie in Dallas who is considering becoming a perlmonk since he consults this site several times daily)

      Rad,
      You should join into Perlmonks. Along with the ability to post you get the added feature of the Chatterbox. Which has help me almost as much as posting.

      --BigJoe
RE: One Big script or many little ones?
by Ovid (Cardinal) on Jun 15, 2000 at 20:58 UTC
    Take a look at those several scripts and see how they relate to one another. It's good to put those scripts into modules where they can be reused.

    For myself, I find that when I am coding, I often develop a series of "favorite techniques" that have a similar theme (like being CGI or DBI related). When I do that, I think it's good to take those separate bits of code and combine them into one module of related functions. For you, instead of having 5 scripts, you might only have two, if their functions are combined along similar lines.

    It sounds to me like what you are doing is creating modular code. This is a Good Thing. Just as Larry Wall (I think) said that a program should do one thing and do it well, a module should do one thing (or handle one set of related tasks) and do it well.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2022-05-26 11:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (93 votes). Check out past polls.

    Notices?