Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (2)
As of 2016-08-31 03:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The best thing I ever won in a lottery was:















    Results (426 votes). Check out past polls.