Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re^5: The joys of bad code

by hardburn (Abbot)
on Oct 26, 2004 at 18:30 UTC ( #402751=note: print w/replies, xml ) Need Help??

in reply to Re^4: The joys of bad code
in thread The joys of bad code

An array would work just fine in this case. For things like this, I tend to automatically (for better or for worse) reach for a hash, as I usually need to do the lookup based on a string.

Even so, I don't think the orginal VB code is so bad. The switch statement is probably going to be O(n) (since it can't optimize down to a jump like C's less flexible switch statement can), but the search space is so small that it won't matter much.

I do wonder, though, if this function should be public. If the application is properly OO, this is the sort of detail that should probably be hidden away. I'd have to know more about the overall application to be sure, though.

"There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://402751]
[shmem]: hmm module takeover... any hints? I'm being lazy wrt searches
[choroba]: Contact the author, ask other to help contacting the author, write to pause admins
[shmem]: ah perlfaq7
[shmem]: thanks choroba, found it. 'Tis about MJD Devel::Trace
[shmem]: I'd like to upload a v0.13
[choroba]: Very nice!

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (9)
As of 2018-02-23 14:52 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (302 votes). Check out past polls.