6.4. Variable, Function and Type Names

Type names must be descriptive [Type name: 1-4 points]

Choose sensible type names. If a type is used to describe a vertex, call it vertex, not graph. If a type describes one edge, call it edge, not edges.

Function names must be descriptive [Function name: 1-5 points]

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

Do not choose a misleading name. A function that removes something should not be called insert. A function that prints a tree should not be called showlist. If a function does not create an edge, do not call it createEdge. Use common sense.

Avoid function 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.

Descriptive variable names must describe the correct thing [Variable name: 1-4 points]

You are encouraged to use descriptive variable names, as long as they do not become so long that they are unwieldy.

A descriptive variable 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.

Field names of structure types must be descriptive.

Avoid single-letter names for fields of structures. Choose sensible, descriptive names.

Do not use l, o or O for variable or names [Confusing name: 1 point]

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. Do not use those names. You may use L.