variables

How Not To Pick Variables

Submitted by jean-paul on Sat, 09/29/2012 - 01:40

Here is a small example showing how choosing good variable names can make a huge difference. Look at the following code block, and see how long it takes you to work out what it does. If you find it takes you a while, look at the improved code below that and see how much easier it is! Even with short variables that are words, not being descriptive makes debugging very difficult. Using letters on their own is frequently worse. Both code blocks are functionally identical, only variable names are changed.