[Chicago-talk] PBP - What to name a hash_ref?
Steven Lembark
lembark at wrkhors.com
Mon Oct 17 16:18:59 PDT 2005
> Actually on re-reading, PBP recommends ending the hash name in a
> preposition specifically:
>
> "Moreover, because hashes often store a property that's related to their
> key, it's often even more readable to name a hash with a singular noun
> followed by a preposition"
>
> $author_of{'Perl Best Practices'} = 'Damian Conway';
>
> Ironically, he goes on to give some examples that don't end in a
> preposition. I guess it's more of a guide-line. Try to make it read
> naturally.
The point was to make the variable names mean something
in the context they are used. If you get a fragement like
for my $g ( keys %phntyp )
{
...
}
You are less likely to guess/remember that it means
for my $gene ( keys %phenotype_map )
{
...
}
Using "%authorz" would probalby be sufficient for most
uses, that or you could try %authors_of_books_by_title...
At some point context and <gasp!> comments are necessary
for getting the stuff done.
--
Steven Lembark 85-09 90th Street
Workhorse Computing Woodhaven, NY 11421
lembark at wrkhors.com 1 888 359 3508
More information about the Chicago-talk
mailing list