[kw-pm] a philosophical question about hashes

John Macdonald john at perlwolf.com
Thu Jun 16 10:37:32 PDT 2005


There are certainly times when having the key inside the
value is useful.  If you have a subroutine that operates
on a single value record, it could easily need to know
the value of the key as well as the others parts of the
record.  It's easier to pass it a single coherent value
than to have to pass the key as well.

    process_record( $structure{$_} ) for (@interesting_keys);


On Thu, Jun 16, 2005 at 10:51:39AM -0400, Greg.Fenton at sybase.com wrote:
> [Sorry if this is a dupe....our IT organization cannot keep our domain 
> name straight so some posts have been bouncing]
> 
> To me, this is a "normalization" question, akin to relational database 
> normalization.  The ultimate goal of any database design is to be as 
> normalized as possible, reducing duplication and segmenting data into 
> tightly focused groupings.
> 
> However, there are certainly patterns in relational design where 
> over-normalization leads to poor performance or unwieldly complex code 
> (queries).  To that end, there are definitely times where denormalization 
> makes complete sense (reality vs. purism).
> 
> greg.fenton
> ----
> Greg Fenton
> Consultant, Solution Services
> iAnywhere Solutions
> 
> 
> 
> "Robert P. J. Day" <rpjday at mindspring.com> 
> Sent by: kw-pm-bounces at pm.org
> 06/15/2005 07:30 PM
> 
> To
> Christopher Calzonetti <elbie at trig.net>
> cc
> KW Perl list <kw-pm at mail.pm.org>
> Subject
> Re: [kw-pm] a philosophical question about hashes
> 
> 
> 
> 
> 
> 
> On Wed, 15 Jun 2005, Christopher Calzonetti wrote:
> 
> > On Wed, Jun 15, 2005 at 04:33:39PM -0400, 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?
> >
> > I can see at least one reason for doing this:
> >
> > Say there are a bunch of different unique identifiers for a record,
> > and you point to a reference that contains the full record.
> >
> > In your example, you might also have a hash based on driver's
> > license number, and you want to use the same records.  Well then,
> > the record would need the SSN/SIN, as it wouldn't be the index.
> 
> i'd thought of that as well.  i *can* see the value in the
> duplication, i was just wondering if anyone had strong opinions on
> this either way.
> 
> rday
> _______________________________________________
> kw-pm mailing list
> kw-pm at pm.org
> http://mail.pm.org/mailman/listinfo/kw-pm
> 
> 

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