6.3. Variable and Function Names

Function names must be descriptive [FUNCTION-NAME]

Choose a name for a function that suggests what the function does. Do not choose unnecessarily long function names, but make the names sensible.

Variable names may be descriptive

You are allowed to use short and simple names for variables where appropriate, such as loop counters. You can also use descriptive names for variables, and that is usually better. Do not use descriptive names that are unwieldy and that make the program more difficult to read.

Descriptive names must describe the correct thing [VARIABLE-NAME]

A descriptive variable or function name must make sense. If something is a horse, do not call it kangaroo. If something is an edge, do not call it vertex. The maximum size of an array of edges must not be called MaxNumVertices. If a function does not create an edge, do not call it createEdge.

Avoid descriptive names that are so vague that they do not really describe anything. For example, a function called createArray presumably creates an array. That is fine if all it does is create an array. But that is not very useful if what it really does is create and initialize an array for a specific purpose. It is better to choose a name that is descriptive of the purpose.

Do not use l, o or O for variable or names [CONFUSING-NAME]

Names l (lower case ell), o (lower case o) and O (upper case O) tend to be confusing. It is easy, for example, to confuse l with 1. You may use L.