//STYLE: Use descriptive variable names

Always choose self-describing variable names

Don't you hate it when people don't say what they mean?

Sometimes this happens when people think you understand, but they have not given you enough information to get the full picture.

The same thing happens in programming when you don't name things thoughtfully.

Use camelCase for variables

In most languages, you cannot have a space in a variable name.

In order to still have descriptive names without spaces, you have to use camelCase. camelCase has all the words grouped together, and has the first word lowercase, and the first letter of all remaining words capitalized.

Use ALL_CAPS for constants

An exception to using camelCase is when you are defining a constant.

A constant is a variable that never changes. It holds data that is used, but never modified. Traditionally, constants are spelled in ALL_CAPS with underscores where the spaces would go.

It is also a good idea to use const instead of var if you know that the value is never going to change.

Be descriptive

Although you will type less by using short, difficult to understand variable names, You will lose that time later when you are trying to figure out what each variable does.

Use abbreviations sparingly

There are times when abbreviations are OK, such as when they are already used commonly in writing (texting shorthand does not count).

In general, if you are making up your own abbreviations, they are probably going to be confusing to other people.

There are some commonly used abbreviations in programming, however:

Most variable names should be nouns

It is generally a good idea to avoid using verbs, adjectives, adverbs, etc. for variable names. If your variable name is not a noun, you are probably not communicating well.

BUT! Use questions for boolean (true || false) variables

Boolean variables are a lot like a true or false answer to a question. In fact, it often makes sense to use a question for a boolean variable name.

Include the variable type for objects and arrays

Most variables are straight-forward number or string variables. Programmers assume this when they are reading code.

If your variable is for a more complex data structure, then hint at that data structure in its name.