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

RE: Define consistent and standard

Thread Previous | Thread Next
Garrett Goebel
August 11, 2000 08:18
RE: Define consistent and standard
Message ID:
From: []
> What I was trying to get across was that if you're storing 
> more than one email address per person, you might use
> %email_addresses and therefore $email_addresses{Skud}, whereas
> if you're limiting it to one email address per person, it would be
> $email_address{Skud}.

Makes sense after a fashion. Though I'm a little out of fashion ;)

  Scalar = thing
  Hash   = thing(s)
  Array  = thing(s)

That is fundamental an unalterable. Storing a reference to an array in a
scalar, is still storing "a" reference. When I see $email_address, I know
I'm seeing a single thing. When I see %email_addresses, I know it'll hold
one or more things.

Determining the plurality of a hash or array's name based on the content of
their values as Kirrily/Netizen suggest, is fine so long as the programmer
adheres to the naming convention. Still, what's a person to name a hash when
it holds something motley like:

%email_addresse(s)? = (Skud => [qw(],
                       dud  => '');

On the other hand, if you advise making all scalars singular nouns, and all
hashes and arrays plural, then you don't have the self-imposed worry about
the contents of your arrays and hashes. If you name your hash
%email_addresses, you can fill it hash with scalars values one week and
anonymous hashes the next (or mix-and-match). You don't need to go through
your code and update $email_address{Skud} to $email_addresses{Skud}. 


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