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.
- You must be able to execute your code.
- In particular, if a test program is provided, then code must execute with the test program.
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
- Code should be neat and readable.
- Code should conform to standard conventions.
(E.g., for C++ this would involve
the conventional use of header and source files
const
-correctness, etc.). - All comments in the code should be correct.
-
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.
- 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.)
- 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.
- 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
- 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.) - Before each defined function or larger entity (e.g., a C++ class) should be comments indicating its purpose.