Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Is there an ideal module size or subroutine size?

by p6steve (Sexton)
on Aug 17, 2007 at 21:52 UTC ( [id://633400]=note: print w/replies, xml ) Need Help??


in reply to Is there an ideal module size or subroutine size?

Well - I am an intermediate level (perl) programmer and I use a couple of rules of thumb:
  • create a sub where you use the same code more than once (that means twice!, or more)
  • generalize subs via parameters to avoid having multiple similar subs
  • if you have a long (ie >500 line) sequence of "meat & potatoes" code, then it is a good idea to reduce your "main" routine to a 30 line-ish sequence of calls to subs ... this is really a way to self document the code and forces you to limit use of global variables to make the code more re-usable
  • Comment on Re: Is there an ideal module size or subroutine size?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-04-24 19:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found