note
FoxtrotUniform
<p>Instead of an admonition ("Short variable names are bad!
Unless...") I'd suggest a more generous rule:</p>
<p><i>The verbosity of a name should be proportional to its
scope</i></p>
<p>If my program's a one-liner, then <tt>$i</tt> is fine for
pretty much any purpose. (Although using <tt>$i</tt> as a
real number would probably weird me out.) In a longer
program, <tt>$i</tt> is probably too short for anything but
a loop variable, or maybe an increment in a short function.
</p>
<p>In general, I try to use the shortest name possible that
doesn't need an explanatory comment. So, if I'm working
with vertices:</p>
<code>
for my $v (@verts) {
...
}
...
sub centroid
{
my @verts = @_;
...
}
...
package Graphics::Model;
...
@Graphics::Model::vertices = ();
</code>
<p>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.</p>
<p><tt>-- <br>
The hell with [paco], vote for [Erudil]!<br>
/msg me if you downvote this node, please.<br>
:wq</tt></p>
170911
170911