Programming Guidelines
The following guidelines are worded strongly. This means exceptions
exist, but if you intend to violate one of them then you should have a
good reason.
- The first line of any file (code or documentation) must include
authors name.
- The second line of any file must include purpose of file (usually
project number).
- A file should contain only one class.
- Proper indentation is madatory (strongly suggest 3 spaces per
block).
- Mixing tabs and spaces is unacceptable (just because the
indentation looks correct in your application doesn't mean it will be
correct when viewed by my application).
- Appropriate commenting is necessary (typically should be
approximately 20% of the lines of a program).
- Comments must be useful (describe pupose of blocks of code not
simple translations of single lines).
- Use whitespace to increase readability.
- Lines should never be longer than 80 characters (preferably 60).
- A line should include only one command.
- Fields and helper methods should be private (or at least
protected).
- Methods should be no more than 50 lines (use helper methods).
- Methods, variables, and classes should have helpful names (i,j,k
for index variables, get/set for accessors/mutators, others should
reflect meaning/purpose).
- Method, variable, and class names should be capitalized correctly
(class names have first letter of every word capitalized,
methods/variables have first letter of all but the first word
capitalized).
- Simple solutions are better than complex ones.
To be continued.