Variables, for those who don’t understand what I mean, are essential in programming. A variable consists of a space in the storage system (the computer’s main memory) and a symbolic name (an identifier) associated with that space.

The easiest example, in my opinion, is to think of it as a drawer. The variable is that drawer where we can store information.

My problem, and the problem of many others, is knowing what name to give certain variables. I know programmers who even use swear words 😱. Yes, you read that right: swear words. The simplest thing I’ve seen is something like: var DAMNIT = 0.

In my case, I tend to use names like variable1, which is wrong because it leaves the code messy and hard to read (just like my early blog posts 😅). Variables are supposed to be understandable in terms of what they do and the information they manage. So, here are a few tips that have worked for me:

  1. Try to describe the entire word; use underscores _ if necessary.
  2. Use CamelCase.

There are two types of CamelCase:

  • UpperCamelCase: where the first letter of each word is capitalized. Example: ExampleOfUpperCamelCase.
  • lowerCamelCase: similar to the above, but the first letter is lowercase. Example: exampleOfLowerCamelCase.

Tell me about your experience naming variables! And if you have better tips than I do, feel free to share them!