SWEN 221 Programming Style Guide

Here are a few basic style guidelines you should consider with respect to your lab and assignment submissions:

  1. Naming conventions. Names (such as for classes and variables) should always reflect the meaning of the item in question. Using a consistent naming convention is also important. For example, in Java the following conventions are common:

    • Class names are capitalised, with internal words also capitalised. For example: NinjaKitten.
    • Local and protected/private variables have internal words capitalised only. For example: kittenHealth.
    • Likewise, method names have internal words capitalised only. For example: isClawed().
    • Constant names use all capitals. For example: PLANKS_CONSTANT

  1. Comments. Good comments which accurately reflect and clearly communicate what the code is supposed to achieve are important. This does not mean that you should comment each line, in particular not by restating what is evident from the code alone. Self-explanatory naming choices for the code will go a long way of supporting code understanding and comments should not restate Java semantics but rather motivate why the code is there, explain what its ultimate purpose is, and elaborate what the principles underlying its design are.

There are many discussions of what constitutes good programming style on the internet. A good starting point is Doug Lea's Draft Java Coding Standard and a local copy is available here. The guidelines expressed in this standard will be used in marking your submissions.