Indentation

switch statements get special indentation, as they can otherwise waste a lot of space:

switch(variable)
{
case ValueOne:
   ActionOne();
   break;

case ValueTwo:
   ActionTwo();
   break;

default:
   assert("bad Action");
   break;
}

Keep all lines fairly short, and break the line if it will scroll off to the right. If you do break a line, indent the following lines. Try to break the line at a reasonable place, and if there is an operator, leave it at the end of the previous line (as opposed to the beginning of the following line). This way, it is clear that the line does not stand alone and that there is more to come.

© 1998 by Wrox Press. All rights reserved.