[Brisbane-pm] Passing 2d Arrays ctd...

Andrew Savige ajsavige at yahoo.com.au
Thu Feb 22 21:58:47 PST 2007


--- Martin Jacobs wrote:
> Thanks to the tip about $a. I was trying to avoid  
> $variables_with_really_long_names, but at least  
> $variables_with_really_long_names tell you what they are,
> and there's little likelihood of confusing them with
> something that refers to something else.

Chapter 1 of "The Practice of Programming" by Kernighan and Pike:

 http://cm.bell-labs.com/cm/cs/tpop/

has some sound naming advice: use short names for short scopes,
longer names for larger scopes. In particular, globals are
dangerous and ugly and so usually warrant very long names (also
making it easier to search for all occurrences of their use).

For example, $i may be appropriate for a loop containing only
one statement, such as: 

 for my $i (0 .. $some_magic_number) {
     # one statement only
 }

whereas it's probably too short if the loop body consists of
20 or more statements.

In addition to that, Damian discusses Naming Conventions at length
is his "Perl Best Practices" book in Chapter 3 (you'll need to buy
the book for that chapter). One example he gives is on forming
effective abbreviations: for example, "maximum length" is better
abbreviated as $max_len rather than $mx_lngth.

Cheers,
/-\


Send instant messages to your online friends http://au.messenger.yahoo.com 


More information about the Brisbane-pm mailing list