Style Guide

Motivation

Some of the reasons for using a style guide are:

Overview

The explicit rules listed on this page are designed to help you avoid some obvious code style violations. You should also look at the existing code and make your code as consistent as possible.

Style guide complicance is, however, not nearly as important as high quality code. If your code uses high quality coding standards, your instructor will be much more lenient on any small differences in code style.

Explicit Rules

Indentation

Indent to show structure. Use 3 spaces to indent. Do not use tab characters.

Where possible, configure editors to insert spaces instead of tab characters - the tab character is interpreted differently by different programs and its use in the formatting of code should be avoided.

Naming conventions

Brace placement

void useBracesLikeThis(int x)
{
   // Always add braces, even if it's only a single statement.
   if (x < 3)
   {
      cerr << "well done" << endl;
   }
}

Use C++ instead of C

Be a C++ programmer as much as possible, for example:

Miscellaneous

Last edited Mon Jun 4 21:14:14 2007 by John Funge.