Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Style & subroutine organization

by Maclir (Curate)
on Aug 29, 2001 at 21:39 UTC ( [id://108818]=note: print w/replies, xml ) Need Help??


in reply to Style & subroutine organization

I would have to support the first option. As a rule of thumb, it is generally considered "good practice" to have all of the declarations for a block of code at the top, along with a concise description of any declarations that may add to readibility.

One other thing to consider is the size (in lines of code) of each subroutine. In my early days as a Cobol programmer, the site standards specified that a subroutine should not be longer than two pages of standard 66 line fanfold printout. That way, you could see the complete subroutine at a single opening of the printout binder. Now, we have long since moved beyond filing out program listings in binders of 132 x 66 sized listings, but the idea still has validity - you should be able to take in the who subroutine at a single reading. Hence, make each routine do a single task - no side effects.

Log In?
Username:
Password:

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

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

    No recent polls found