CS 331 Spring 2019  >  Coding Standards


CS 331 Spring 2019
Coding Standards

The following standards apply to all submitted code in this class.

Of first importance are the following.

The above requirements are absolute; if you cannot compile/execute your code, then there is no point in turning it in.

In addition, to receive full credit, submitted code should satisfy the following conditions.

1. General Standards

  1. Code should be neat and readable.
  2. Code should conform to standard conventions. (E.g., for C++ this would involve the conventional use of header and source files const-correctness, etc.).
  3. All comments in the code should be correct.
  4. Code should not perform any actions visible to the client code or the user, other than those in its specification.
    • Debugging printout is a great idea, but before you submit your code, turn it off.
    • Avoid unnecessary creation or alteration of data visible to the client code.
  5. Code should not place any arbitrary limits on data. (An example of an arbitrary limit would be requiring a line typed by the user to be at most 100 characters long.)
  6. Code should actually perform the required computations. Hacks that only work with the exact input given by a test program will not be counted as fully correct.
  7. Programs may be partially based on code written by someone else. However:
    • Your submissions should be largely your own design, and a significant portion of the code should be your own work.
    • You must give credit in the code to the author of any code that is included (in original or modified form) in your submission.
    • Code written by others may only be used in a way that does not violate applicable laws and licenses.

2. Specific Standards

  1. At the beginning of every file should be comments indicating the file’s name, author(s), last revision date, and purpose. (The purpose comment does not need to be very long. Something like “Header for class Foo” is generally fine.)
  2. Before each defined function or larger entity (e.g., a C++ class) should be comments indicating its purpose.