[kw-pm] a philosophical question about hashes

Daniel R. Allen daniel at coder.com
Wed Jun 15 13:49:56 PDT 2005


It might be more convenient to have the key repeated; it doesn't strike me
as terribly inelegant.

It could make accessing the key back out again, simpler.  You could
alternately do that by treating the key as a special case when retrieving
all the values, but that's a bit more code, by my thinking.

-Daniel

--
drallen at cs.uwaterloo.ca - Linux software specialist - (519) 888-4567 x6975
http://coder.com/ - Prescient Code Solutions - (519) 575-3733 da at coder.com
http://kw.pm.org/ - Kitchener-Waterloo Perl Mongers -         da at kw.pm.org

On Wed, 15 Jun 2005, Robert P. J. Day wrote:

>
>   not so much a perl question as a software design question that just
> happens to be associated with perl -- is it considered bad form to
> create a hash in which each element's key is also one of its fields in
> the corresponding value?
>
>   obviously, there would be some redundancy there -- it would be
> tantamount to, say, having a hash keyed on a social insurance number,
> and the value being another hash, one of whose elements was, again,
> the SIN.
>
>   the duplication there just rubs me the wrong way, but i'm looking at
> some existing code that has that property and i'm trying to convince
> myself that there's no real justification for it.
>
>   thoughts?
>
> rday
> _______________________________________________
> kw-pm mailing list
> kw-pm at pm.org
> http://mail.pm.org/mailman/listinfo/kw-pm
>



More information about the kw-pm mailing list