Giving Names to the Unnamed

Giving Names to the Unnamed

Other than making sure existing variable names are good, one of the first and most important things you can learn about variable naming in code is that there are many things that would otherwise be “unnamed” that you can give names to. In many cases, the extra names can bring extra clarity and meaning that is beneficial to the long-term readability and maintainability of code.

Creating variables for every single little thing in code may not always be the best choice. However, strive to make sure that you could give variable names to everything if needed. Being unable to come up with at least a semi-decent name is a warning sign that you may not yet fully understand the problem. In such a case, spend time studying and understanding the problem to make sure you can get your code right, introducing variable names as-is helpful.

The following sections of training show how names can be helpful in various circumstances: