Scripter Javascript Tutorial
javascriptmusiclogicscripterbookexcerpttutorial82 Variable and Function Names
Variable and functions are one of the single biggest sources of bugs in a script. Good naming of variables and functions will go a long way towards avoiding mistakes later on. Like commenting, variable names should be clear and concise. Good variable names combined with good comments will make code more readable and maintainable. Troubleshooting errors will be made easier by naming things for what they really are.
There are many examples, especially in loops which typically use only
a single character for the loop variable, but every piece of data means
something to the script and its author. A single character can be fine
when the purpose of that character is abundantly clear, like with basic
data types— “s
” for a string, “i
” or
“n
” for a number. Otherwise, an actual word should be
used.