SoftwareStandards
Software Standards
Overview
- Overall, the simpler the code, the better. Writing a complex statement is usually not the best way to code. Writing two or three simple statements instead is much better.
- Avoiding defaults is preferred. It saves little. Stating it instead of assuming it makes it explicit and easier for the next developer. In addition, defaults may vary based on the language. Developing a dependence on them is not good.
- In most cases, a more readable code is preferred to code that optimizes at the statement level. This optimization can almost always be achieved by the compiler/interpreter. Therefore its benefit is minimal at the coding level. Readablity is essential for good code
Documentation
A properly documented software project includes the following:
- Each source code file includes a header comment that includes:
/******************************************************** * Author:> author name> * Course: course code (i.e. CSC 121) * Assignment: assignment name ********************************************************/
- If the file is the main file, then the header should also include (before the ending stars) :
* Problem: short problem description
- Else it should include (before the ending stars):
* Purpose: short description as to the purpose of that file
- If the file is the main file, then the header should also include (before the ending stars) :
- Each variable that is not self-evident to an independent reader should have a comment indicating its purpose.
- Each method that is non-trivial must have a single simple sentence stating its purpose. Trivial methods are defined as one line methods, or extremely obvious to the independent reader.
- Any complex section of code, must have a comment explaining the logic
Style Requirements
- At least one constructor
- An accessor for each field variable
- A modifier for each field variable that is allowed to change
- Standard methods including: toString, equals, and possible compareTo