What Should I Name My Variables?
I'm glad you asked. Hardcore programmers frequently use the smallest
names they can get away with, because they are typing all day long, and
shorter variable names equals less typing.
Bah. Most of these scripts won't be more than a day or two of work, and
short, cryptic variable names mean that your program will be hard to read.
And yes, that script that you lovingly slaved away at for two days will
look like so much gibberish to you three months later when you need to
go in and tweak something.
So use variable names that best describe what cargo they hold.
myName = "Sean
Hyde-Moyer";
colorOfPants = "Red";
favoriteNumber = "6";
freshBakedPi = 3.14159;
booleanFlag = "TRUE";
What's with the Crazy Captitalization?
Frequently, you'll see variables names written like this:
someName
anotherBrick
redPants
clownNose
What's the deal? Well, LScript commands (and this is true for a lot of
languages) are all lower case. So, when coders make variables, they sometimes
add a capital letter in there to differentiate it from a command.
Why in the middle, and not at the beginning? Probably to look cool, and
feel special. More than likely, it's because when we type in our everyday
non-coding lives, we captialize the beginning of a sentence. Since capitalization
can mean bugs if used in the wrong place in a script, placing a capital
in the middle of a variable name is a habit that can be used to counter
our impulse to put a capital at the begining of a line.
In addition, since variable names can't have spaces in them, capsAtTheBeginingOfWordsMakesItALittleEasierToRead.
Bear in mind, I'm making most of this stuff up. |