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

Mark Swindell mdswindell at cruzio.com
Mon Feb 20 12:27:28 EST 2006


Rob,

I agree wholeheartedly with you on this.  Switch statements are not  
hard to comprehend once you've got some mental velcro to hang them  
onto, some preexisting knowledge to connect to.  They are imposing  
when you don't have that.

Two conditions need to be met for most programming newbies to get it:
1. If then else construct is learned and understood
2. Switch is _taught_ through referencing the if then else concept,  
and the new parallel switch syntax and its value are introduced

The problem with most of this for newbies is they are not being  
_taught_ much of anything, but rather having to figure it out on  
their own by scrubbing the docs, which takes them out of the learning/ 
solving  mode and into the foraging/frustration mode.

Mark



On Feb 20, 2006, at 8:13 AM, Rob Cozens wrote:

> Judy, et al:
>
>> If-Thens are readily comprehensible by non/novice-programmers.
>>
>
> And by extension, switch statements are not. [?]
>
> When I gave you this point in an earlier post, I was really  
> conceding that the syntax of a switch statement does not flow in  
> the same English-like fashion of "ifs" in xTalk.
>
> Maybe I've been at it too long to see the forest for the trees; but  
> I truly don't see what is so hard to comprehend about the switch  
> concept.  One identifies  a switch value and specifies different  
> logic paths to follow depending on the value of the switch.
>
> 	on menuPick thePick
> 		switch thePick
> 			case "Cut"
> 				...
> 				break
> 			case "Copy"
> 				...
> 				break
> 			case "Paste"
> 				...
> 				break
> 			[etc.]
> 			default
> 				answer warning quote&thePick&quote&&"is not supported!"
> 		end switch
> 	end menuPick
>
> It can be explained in terms of if/then/else--which you find easily  
> comprehended--; so when it's explained in that context it should be  
> readily understood....no?
>
> Again, I'll grant you that there is more to switches than that  
> simple example shows; but the basic concept is not that difficult  
> to understand or explain (to me; but I have to defer to your  
> classroom experience, as unintuitive as it is to moi).
>
> Rob Cozens
> CCW, Serendipity Software Company
>
> "And I, which was two fooles, do so grow three;
> Who are a little wise, the best fooles bee."
>
> from "The Triple Foole" by John Donne (1572-1631)
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>




More information about the use-livecode mailing list