On Jun 20, 2007, at 8:59 PM, Kay C Lan wrote:
Devin although I know your after 'Coding Best Practices' along the
lines of
naming objects and variables with meaningful names, and using
prefixes for
local/global/constants, then if you're compiling a list of tips for
debugging (assuming you don't use explicitVars)
Step through your script with the Variable Watcher open
1) Are there two variables that are almost identical
lMyColourVariable and lMyColorVariable
2) Have I used gMyColour where I should have used lMyColour or
pMyColour
Having eliminated these two common errors (for me anyway) it pretty
well
only leaves an error in the algorithm logic - which of course is
the fun
part of tweaking code to get the right algorithm.
These are great suggestions. I'll include them when I talk about
debugging in my class.
<snip> Some details about switching from nested if/then/else to
switch structures.</snip>
Since then, for any conditional statements, unless I know 110% that
the
condition will NEVER be anything other than 2 options, Yes/No,
Right/Wrong
then I ALWAYS use Switch.
<snip> more details </snip>
I tend to use your 3 line rule, in that if the statements in the
case exceed
3 lines I'll write a separate handler. As such, the switch
structures appear
very concise and very logical (to me) as to what they do and why.
I don't suggest a Best Practice for Switch statements, but if you
can help
get the 'penny to drop' I think they can really help in keeping code
readable, manageable and best of all, very easily extensible.
I agree. After about three else clauses an if/then/else structure
starts to look pretty messy. I'm warming more and more to switch as
time goes on. At three conditions I start to consider whether switch
might be more appropriate than if/then/else.
Regards,
Devin
Devin Asay
Humanities Technology and Research Support Center
Brigham Young University
_______________________________________________
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