Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Of variable {mice} and its name {man}.

by FoxtrotUniform (Prior)
on Jun 02, 2002 at 20:07 UTC ( #171060=note: print w/ replies, xml ) Need Help??


in reply to Of variable {mice} and its name {man}.

Instead of an admonition ("Short variable names are bad! Unless...") I'd suggest a more generous rule:

The verbosity of a name should be proportional to its scope

If my program's a one-liner, then $i is fine for pretty much any purpose. (Although using $i as a real number would probably weird me out.) In a longer program, $i is probably too short for anything but a loop variable, or maybe an increment in a short function.

In general, I try to use the shortest name possible that doesn't need an explanatory comment. So, if I'm working with vertices:

for my $v (@verts) { ... } ... sub centroid { my @verts = @_; ... } ... package Graphics::Model; ... @Graphics::Model::vertices = ();

I guess my point is that it's not the length of the name that matters (gnarf gnarf), but whether you need to comment it.

--
The hell with paco, vote for Erudil!
/msg me if you downvote this node, please.
:wq


Comment on Re: Of variable {mice} and its name {man}.
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (16)
As of 2015-07-01 17:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (12 votes), past polls