CS 213 Coding Standard

An important and often overlooked part of participating in a software engineering environment is the production of readable code.  To aid in that end, many organizations enforce rigid standards on how code is written.  The intention is to unify variable naming conventions and to rule out from usage aspects of the language that are either less than explicit or which have the potential to cause nasty side effects.

For the purposes of this class, we will have a very basic coding standard.  The standard is intended to promote good coding style and help the grader understand your code.

Additions to this document will be made throughout the semester as we cover more features of the language.

The Rules:

  1. All files must include a header block that contains at a minimum the name of the author, the date written and the assignment to which the code pertains.
  2. Always use ( ) to make explicit the order of operations in an arithmetic expression when more than one operator is present.
  3. Never use the return value of an assignment or I/O operator as a test in a conditional.
  4. Identifiers are to be named as a sequence of descriptive capitalized words and be free of underscores.  Ex.  int ProductMatrixSize = 2;

General Rule:  ALWAYS BE EXPLICIT.  Modern compilers are smart; they can often optimize out additional statements put in make code explicit; even when they can't, the saving of writing obscure, fast code rarely compensates for the time spent debugging it because you can't figure out (or remember) what it does.  BE EXPLICIT!   Comments are thrown out during the compilers first pass.  USE COMMENTS LIBERALLY!


This page was last edited:  Tuesday, December 14, 2004 12:17:55 PM