6.3. Variable, Method and Class Names

Class names must be descriptive [CLASS-NAME: 1-4 points]

Choose sensible class names. If a class is used to describe a vertex, call it Vertex, not Graph. If a class describes one edge, call it Edge, not Edges.

Method names must be descriptive [METHOD-NAME: 1-4 points]

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

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

Avoid method names that are so vague that they do not really describe anything. For example, a method 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.


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.