Switch versus if/then/else ( was: Main menu puzzle, Klaus)

Richard Gaskin ambassador at fourthworld.com
Sun Feb 19 15:34:07 CST 2006

Graham Samuel wrote:
> On  Sun, 19 Feb 2006 10:37:36 -0800 (PST), Judy Perry 
> <jperryl at ecs.fullerton.edu> wrote:
>> Mark,
>> Right, again, my argument was less "IF-THENs rule and CASE-SWITCHes suck"
>> than IF-THENs are easier to read/learn/are more transparent for
>> non/novice-programmers.
> Just to add a tiny footnote to this: Judy, how would you tackle a 
> situation where a user (or a handler) can put in say a number from 1 to 
> 50, and each of those numbers requires the program to carry out a 
> different action? It wouldn't really be feasible to have a depth of 50 
> if-then-elses

Teaching the whole of the art of programming in a single session or even 
a single semester would likely overwhelm the student and the teacher. 
If a given construct seems a bit daunting for the first semester or the 
first year, there's plenty of time to introduce it later.

Learnability and usability are different goals.  If switch/case blocks 
seem a bit much for the learner, that takes nothing away from the 
graceful utility which has made them a cornerstone of so many languages.

Switch/case blocks may be best learned in the second semester anyway: 
if the first semesters goes well, by the end of it the learner may have 
already begun to find the limitations of if/then and is hungry for 
something else....

  Richard Gaskin
  Managing Editor, revJournal
  Rev tips, tutorials and more: http://www.revJournal.com

More information about the use-livecode mailing list