CS 331 Spring 2025  >  Coding Standards


CS 331 Spring 2025
Coding Standards

The following standards apply to all source code turned in this semester.

Of first importance are the following.

Code that does not meet the above standard will not be graded.

If you cannot get code to compile/execute, then I am happy to help you figure out what the trouble is. However, for code turned in for a grade, the above requirements are absolute; if you cannot execute your code, then there is no point in turning it in.

1. High Quality Code

Code must be of high quality. In particular:

  1. Code must be neat and readable, with consistent indentation where appropriate and proper use of whitespace.
  2. All comments in the code must be correct.
  3. Code must conform to standard conventions.
    • E.g., for C++ this would involve the conventional use of header and source files, const-correctness, etc.
  4. Code must 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 work, turn it off.
    • Avoid unnecessary creation or alteration of data visible to the client code.
  5. Code must 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 1000 characters long.
  6. Code must 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.

2. Using the Work of Others

It is understood that very little programming is done from scratch; new programs are based on old programs, often written by others. However, the following standards will apply.
  1. Submitted code must be largely your own work—or the work of your group members, for group assignments.
  2. It is expected that you will only turn in code you understand, regardless of who wrote it.
  3. If a portion of your code was written by someone else, or if a portion of your code is a modified version of someone else’s work, then that person is to be acknowledged in a comment in your code. This includes code written by your instructor.
  4. Any use of someone else’s code must be in accordance with any licenses that accompany the code.

3. Specific Standards

  1. At the beginning of every file must be comments indicating the file’s name, author(s), last revision date, and purpose. (The purpose comment does not have to be very long. Something like “Header for class Foo” is generally fine—for a C++ header file.)