Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: coding rules

by mstone (Deacon)
on Jun 13, 2005 at 04:21 UTC ( [id://466053]=note: print w/replies, xml ) Need Help??


in reply to coding rules

'Nother one to consider: Make the readability of names proportional to their scope.

You don't need long names for short-lived carrier variables:

my $d = $object->{'some'}->{'deeply'}->{'nested'}->{'item'}; _foo ($d->{'bar'}, $d->{'baz'}); $object->validate_range_params ($d->{'bar'}, $d->{'quux'}); { and $d will never be used again after this point }

but it does make sense to use long, descriptive names for things that will be used far away from where they're defined.

The same applies to functions. It's okay to short names for internal functions (the ones you'd start with an underscore), because you won't see them being used unless you're close enough that you can find the definition and read the associated comments. For exported functions, even though people do hate typing the long names, it's worthwhile to add a few characters that will save people from having to RTFS in order to learn what the thing does.

Used consistently, the readability of a name can cue you in to how far you'll have to look to find the original definition.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-19 03:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found