Next: Size and complexity Up: No Title Previous: Reserved words and

Choosing identifiers

One straightforward way to make a program more readable is to choose appropriate identifiers for programs, modules, variables, procedures, functions, parameters, types, constants, record fields (and anywhere else that I haven't thought of). The identifiers that you choose should have mnemonic value, that is, that they should remind the reader what the role or meaning of the identified object is. It is OK to use sensible abbreviations (e.g. Max, Tot).

This rule is flexible when it comes to choosing identifiers for variables which are used in a very temporary way: for example, a for loop control variable where the actual value doesn't have any significance, or a temporary value during a calculation. However, even in these cases, there are common conventions, some arising from traditional mathematical practice, and some just through commonsense: integer variables are I, I1, I2..., J, J1..., real variables are X, X1, X2..., Y..., pointer variables are P..., Q..., temporaries are T....


Simon Jones (sbj@cs.stir.ac.uk)