in reply to Re: A short, "iffy" rant
in thread A short, "iffy" rant
Ut oh, someone has decided to claim "if considered harmful".
If you're referring to my node "if" Considered Harmful in OO programming, I made it clear that this was a specific case of "if" statements being used inappropriately in a particular context. It was not a blanket condemnation of the "if" statement. I made that very clear in the node in question. I chose the hackneyed "considered harmful" title because I have a sense of humor, not a sense of dogmatism.
mapping ifs to hashes just makes hashes of virtual ifs...
I'm sorry, but I disagree. By using a dispatch table, one can frequently add another case to the table and it just works. It's frequently faster. It's a clearer specification of behavior. As your if/elsif/else construct grows, the dispatch solution becomes easier to read and maintain. As my first example shows, it's easy to get incorrect default behavior with if chains and sometimes you have to read through the chain to figure out where your particular statement belongs.
I would not argue that we shouldn't use "if" (my "friends don't let friends ..." comment was meant tongue in cheek.) Instead, I argue that we should take a close look at the logic involved with "if" statements and find ways to eliminate such logic, if feasible. It's far better to be able to create a behavior specification rather than potentially convoluted logic which hopefully covers all possibilities.
Cheers,
Ovid
New address of my CGI Course.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: A short, "iffy" rant
by SpanishInquisition (Pilgrim) on Oct 12, 2004 at 18:40 UTC | |
by dragonchild (Archbishop) on Oct 12, 2004 at 19:09 UTC | |
| |
by Ovid (Cardinal) on Oct 12, 2004 at 19:54 UTC |