Header

Programming Standards

Program Execution

A good computer program performs its task correctly. That is, given valid input, the program generates correct output. A good program anticipates common input errors and responds gracefully to them.

A good program incorporates an interface that is easy to use. When appropriate, on-screen instructions should be provided. When user input is needed, display an easily understood prompt and accept the user's input on the same line. A space should be left between the prompt and the input. To the extent possible, the screen display should be as uncluttered as possible. Often this means leaving one or more blank lines between prompts.

If input and/or output formats are specified, they must be strictly adhered to. In such cases, the programmer must follow the design specifications.

Program Format

A good computer program adheres to established coding standards. Program identifiers should be meaningful. This includes identifiers for constants, variables, functions, classes, and objects.

There should be a program header that identifies the name of the program, the purpose of the program, and information about its author (name, address, date).

Each function should also have a header indicating the name and purpose of the function. The pre- and post-conditions (if any) should be clearly stated. All parameters should be listed according to usage: in, out, or in/out.

A good program contains comments that help the reader understand the purpose of the code.

The bodies of loops, if clauses, else clauses, and switch clauses should be indented. Usually these are indented four spaces though the exact distance is not as important as being consistent.

Program Efficiency

A good program is efficient with respect to performance and memory usage. Execution time can be minimized by the proper use of standard control structures and appropriate placing of statements. Utilize memory efficiently by using only necessary variables and instructions and by using appropriate data structures.