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

Re: Define consistent and standard

Thread Previous | Thread Next
From:
Bart Lateur
Date:
August 7, 2000 12:27
Subject:
Re: Define consistent and standard
Message ID:
llltos0ch66vbrgunndr5rdprodj8p2ho9@4ax.com
On Sun, 6 Aug 2000 01:13:22 +1000, skud@netizen.com.au wrote:

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

Hmmm...

>* 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.

p.s.

>       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.

Pooh.

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

-- 
	Bart.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About