Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

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.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2022-08-17 22:25 GMT
Find Nodes?
    Voting Booth?

    No recent polls found