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

Re^2: Idiom: hashes as sets

by Jenda (Abbot)
on Jul 06, 2008 at 21:06 UTC ( #695872=note: print w/ replies, xml ) Need Help??


in reply to Re: Idiom: hashes as sets
in thread Idiom: hashes as sets

This is why you want to use a CPAN module if the items in your set are not strings or numbers.

If they are and you do not need any advanced set operations, then a module would be an overkill.


Comment on Re^2: Idiom: hashes as sets
Re^3: Idiom: hashes as sets
by dragonchild (Archbishop) on Jul 06, 2008 at 21:09 UTC
    Unless, of course, the following reasons apply:
    • I want to future-proof myself against changing my requirements for membership.
    • I want to future-proof myself against changing my requirements for operations performed on my set.
    • I want to not worry about bugs in my code, but would rather use battle-tested code.

    My criteria for good software:
    1. Does it work?
    2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
      • A set containing some strings and some objects doesn't make much sense and if you switch from a set of strings to a set of objects than the way the set is implemented will be the least of your worries. You'll have to change lots and lots of other things. Besides in such a case Tie::RefHash might very well be enough.
      • You can't presume all future requirements. So any futureproofing is bound to fail.
      • I doubt any module is as well tested as hash operations.
        • A set containing some strings and some objects that behave as strings makes perfect sense to me. For example, a set that contains some strings from user input and other strings that live in a DBM::Deep DB.
        • No, I cannot presume all future requirements. But, I can presume that many future requirements will lead me to places that other peoples' future requirements led them. Therefore, with sets, I can guess that many future requirements will probably require one or more advanced set operations.
        • Given that most sets are implemented as hashes, this is a non-starter. And, the issue isn't one of whether or not the hash operations are going to work. The issue is whether or not my implementation of the pieces of set theory I need will be as correct as that in a well-used module. A hash is not a set.

        My criteria for good software:
        1. Does it work?
        2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (10)
As of 2014-10-01 09:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (392 votes), past polls