Coding Standards

Good code must be readable, maintainable, and make proper use of abstractions, in addition to behaving correctly. As such, we will be grading programming projects not just for functionality, but also for programming practices and style.


We recommend adhering to common style guidelines, such as Google’s style guide for Java. We will not grade every aspect of style, but following a widely used set of guidelines will make your code more readable and maintainable.

The following are the specific requirements your code must follow:


Documentation is necessary for others to understand the purpose of your code. We require the following comments in your code:

Programming Practices

Some projects will also be hand-graded for programming practices such as making appropriate use of object-orientation and avoiding code duplication.


Functions should be short and have a single purpose. If you find yourself writing a long function, figure out a self-contained subtask and write it as a separate function instead.

Use functions to avoid duplicating code. If there are two places in your program that have very similar code, figure out a way to generalize it into a function (e.g. by introducing parameters) and then call that function from both places.

Object Orientation

When writing object-oriented code, make appropriate use of inheritance and polymorphism to avoid code duplication and hard-coding types. Code that is shared among several classes should be written once in a base class and inherited. Derived-class methods that add functionality to that of the base-class method should make a call to the base-class method (using a mechanism such as super) rather than duplicating code. Method overriding should be used to customize behavior in a derived class, rather than type introspection (e.g. instanceof) followed by manual dispatch to custom code. Always use the @Override annotation when overriding a method.