develooper Front page | perl.perl6.stdlib | Postings from August 2000

Re: Define consistent and standard

Thread Previous | Thread Next
Bart Lateur
August 7, 2000 12:27
Re: Define consistent and standard
Message ID:
On Sun, 6 Aug 2000 01:13:22 +1000, wrote:

>* Variables are things are nouns. Give them noun names.
>	$name, $total, $input
>* Plural variables should have plural names
>	@employees, @items, %contact_details


>* Hash names should be written so that looking up an element reads clearly:
>	$email_address{Skud} reads as "the email address of Skud"
>* Hashes with scalars as values should have singular names:
>	my $address = $email_address{Skud};
>* Hashes with arrayrefs or hashrefs as values should have plural names:
>	my @addresses = @{$email_addresses{Skud}};

I can relate to that.

But those two groups of rules contradict each other. Or, do yo want
$email_address{Skud} to be an element of the hash %email_addresses?

I've used both @item and @items as names for arrays. It depends on
whether I always use the data as a whole (@items), or mostly accessing
individual items, as in $item[3]. $items[3] does not look too well.

Yes, I'm being inconsistent, I know.


>       o   While short identifiers like $gotit are probably ok,
>           use underscores to separate words.  It is generally
>           easier to read $var_names_like_this than
>           $VarNamesLikeThis, especially for non-native speakers
>           of English.


But I do like the irony that the latter, $VarNamesLikeThis, is sometimes
called "Camel case": lots of lumps.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About