Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Tied Hashes vs. Objects

by sundialsvc4 (Abbot)
on Oct 22, 2012 at 22:52 UTC ( [id://1000425]=note: print w/replies, xml ) Need Help??


in reply to Tied Hashes vs. Objects

... and I, in like manner, have had some terrible experiences with “tied hashes” that were linked to Berkeley-DB files but that were treated as hashes.   The performance was hideous:   even though a real hash would not have had these problems, it was not a real hash.   But the code that had been written to deal with them, acted as though it was.

If there is any “performance penalty” associated with the object paradigm, and with the understanding/assumption that in your case milliseconds are not in fact all that precious, then I would advocate that the object syntax “wins” because it allows you to write code that reflects what your code actually means, and to do so in only one place.   The implementation code occurs only once.

In the case mentioned above, we found that we had literally hundreds of hot-spots that had to be addressed due to, as it was, a misplaced metaphor.

Replies are listed 'Best First'.
Re^2: Tied Hashes vs. Objects
by tkemmer (Initiate) on Oct 23, 2012 at 07:10 UTC
    I completely agree with you that tied hashes are often misused, the Berkeley-DB interface being one of the most prominent examples. However, in my case the tied hashes really _are_ hashes, i.e. the internal representation would simply be a hash reference, and just some of the accessor methods would be overwritten. I mainly posted my question because usually I shy away from using tied hashes, for exactly the same reasons you give. I think a hash is a very poor interface for anything more complex than, let's say, a hash ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1000425]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2024-04-26 01:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found