When writing programs, code should be as legible and error free as possible. Debugging helps keep code free of errors and documenting helps keep code clear enough to read.
Wherever possible, meaningful names should be used for variableA memory location within a computer program where values are stored., procedureA section of computer code that performs a specific task. and functionA section of code that, when programming, can be called by another part of the program with the purpose of returning one single value.. Look at this simple PythonA high-level programming language.programSequences of instructions for a computer.:
x = int(input("Enter x: "))
y = x * 4
print("y = ")
print(y)
At first glance it may be hard to understand what this program does. It is clear that one number is inputted and another number is outputted, but beyond that it is not clear what the purpose of the program is.
Now look at this simple Python program:
length = int(input("Enter the length of one side: "))
perimeter = length * 4
print("Perimeter of your square is: ")
print(perimeter)
This time it is much easier to determine the purpose of the program (ie to calculate the perimeter of a square). The only difference between the two programs is that the second program uses meaningful names for variables (and in messages).
A meaningful name is one that allows us to easily understand what the variable, procedure or function does or is used for.
Meaningless names make code hard to understand. Sensible and meaningful names make the purpose of code easy to decipher.