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 ( [id://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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2025-07-08 01:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.