Below are coding conventions we will use in our Java programming. These are simplified from an extensive set of rules that we will build up as we learn more features of the Java language.
In later assignments, there will be points allocated in the grading for adhering to correct coding style conventions.
Naming
Names must clearly describe the element they represent.
- Classes: nouns in mixed case with first letter of internal words capitalized
- Methods: verbs in mixed case with first letter lowercase and first letter of internal words capitalized
- Variables: mixed case with first letter lowercase and first letter of internal words capitalized
Indentation
Consistent and clear indentation is essential for readable code.
- Increase level of indentation after all opening curly braces
- Stay at a single level of indentation for an entire block
- Close curly braces at the same level as the corresponding opening curly brace
Other formatting
- Each class must have a comment in this format:
// Name:
// Date:
// Assignment:
// Description: blahblahb
- Start a new line after every “;” or “}”
- Skip exactly one line between methods
- Main must be at the top