Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

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

by p6steve (Sexton)
on Aug 17, 2007 at 21:52 UTC ( #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? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2022-05-17 15:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (66 votes). Check out past polls.

    Notices?