[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Script size limit?



> what is a sane practical file size limit for Perl routines in general?
> Is it better to write one big script with decision trees at the top
> or have several smaller routines that handle specific tasks. I am talking
> pretty exclusively about scripts for web sites here, mostly for Unix servers.

Larger routines are more difficult to maintain than smaller ones.  There
was an interesting study a while back concerning the number of bugs found
in "debugged" (released, in-service) Fortran code.  The study showed that
the number of bugs found went up linearly with the number of routines and
with the square of the average size of the routines.  They also noted some
second-order non-linearities when collections of routines got VERY large.

I write fairly non-idiomatic Perl (Chris sez I'm writing C in Perl :-) and
I comment a fair amount, so my code isn't as dense as some I've seen.  None-
theless, I try to keep my routines down to a few dozen lines of code.  In
my effort to "Macintize" the CPAN for the MacPerl disc, I wrote about 2K
lines of Perl.  FWIW, the files on the Unix side included:

   lines name
   ----- ----
      60 fcd
      10 fw
      24 gll
      27 mp_aty
      32 mp_cns
      78 mp_egf
      17 mp_fbf
      22 mp_ffo
      20 mp_fln
      46 mp_fmp
      36 mp_fmp2
      30 mp_ftp		calls mp_ftp[0-5]
      11 mp_ftp0
     469 mp_ftp1	lots of straight-line (regex line-munging) code
      44 mp_ftp2
     118 mp_ftp3	lots of straight-line (regex line-munging) code
      33 mp_ftp4
     402 mp_ftp5	lots of straight-line (regex line-munging) code
      29 mp_ltf
      74 mp_mtf
      12 mp_oreo
      67 mp_res
      66 mp_rgz		contains three sub's
      33 mp_sad
      28 mp_trim
      47 mp_unix	calls mp_{res,mtf,utf,egf,oreo,rgz,ltf,cns,ftp}
     106 mp_utf

The other question is whether to keep the routines in separate files or
together.  I suspect there are performance penalties to consider, but I
do that one mostly by feel.  The reason all these routines are separate
is that it made it easier for me to debug them.  If I were making up
a set of code to send off, I *might* fold some of them together.

-r

Rich Morin, Canta Forda Computer Laboratory | Prime Time Freeware - quality
  UNIX consulting, training, and writing    | freeware at affordable prices
  P.O. Box 1488, Pacifica, CA, 94044, USA   | www.ptf.com      info@ptf.com
  rdm@cfcl.com            +1 650-873-7841   | +1 408-433-9662   -0727 (Fax)



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch