On Feb 18, 2006, at 3:45 PM, Rob Cozens wrote:

As a programmer, I see any "if" construct with more than two mutually exclusive alternatives as crying out for switch [case] syntax.

Not only is it easier to comprehend the total logic flow, but adding new alternatives is much simpler.

As not a programmer -- as someone who finds it difficult to foresee and pre-design all the branches I'm going to want -- I really agree with this. The trouble with chains of "if" statements is that it's too easy for both me and the language to get befuddled about which "else" goes with who, and when my confusion & the language's confusion don't match, the logic error can be really elusive and I waste a lot of time tracking it down. The "switch" statement feels clunkier, but as long as you don't forget a "break" (a perpetual pitfall) you can always look at the thing and tell what it's meant to do.

Charles

_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to