Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re^2: Perl best practices fanatism

by theorbtwo (Prior)
on Dec 09, 2007 at 20:34 UTC ( #655999=note: print w/replies, xml ) Need Help??

in reply to Re: Perl best practices fanatism
in thread Perl best practices fanatism

The linux kernel coding standards says (amongst other good advice, some of which applies as well to Perl as C:

Functions should be short and sweet, and do just one thing. They should fit on one or two screenfuls of text (the ISO/ANSI screen size is 80x24, as we all know), and do one thing and do that well.

I think it's generally right, if you go on to read the next two paragraphs:

The maximum length of a function is inversely proportional to the complexity and indentation level of that function. So, if you have a conceptually simple function that is just one long (but simple) case-statement, where you have to do lots of small things for a lot of different cases, it's OK to have a longer function.

However, if you have a complex function, and you suspect that a less-than-gifted first-year high-school student might not even understand what the function is all about, you should adhere to the maximum limits all the more closely. Use helper functions with descriptive names (you can ask the compiler to in-line them if you think it's performance-critical, and it will probably do a better job of it than you would have done).

Replies are listed 'Best First'.
Re^3: Perl best practices fanatism
by Joost (Canon) on Dec 14, 2007 at 01:17 UTC

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://655999]
[ambrus]: I don't much like highlighting matching parenthesis, because I've had some bad experiences with distracting implementations of that.

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (11)
As of 2017-02-27 13:01 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (385 votes). Check out past polls.