Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

schwern (1528)

  (email not shown publicly)
AOL IM: MichaelSchwern (Add Buddy, Send Message)

Schwern can destroy CPAN at his whim.

Journal of schwern (1528)

Saturday September 06, 2008
02:49 AM

Context in variable naming.

[ #37368 ]

I'm going through a patch, and came across this

=head3 _sort_pairs
    my @pairs = _sort_pairs($sort_sub, \%hash);
Sorts the pairs of a hash based on keys ordered according
to C<$sort_sub>.
=end private
sub _sort_pairs {
    my $k_sort = shift; # a CODE
    my $hash = shift; # a HASH

Aside from the CS freshman commenting, anything called "$hash" or
"$array" or "$list" is a red flag. Consider the context when naming a
variable. The subroutine is called "sort_pairs" to which one gives
pairs. What's a good name for the variable containing those pairs?
Yes, $pairs.

(Apologies to the patch submitter for being the target of my

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.