Software Style Guide for the Java Programming Language
This document has been developed as a guideline for all future homework submission, to help improve the quality of your programs and programming, where quality is measured in terms of 1) more rapid design, implementation, and test cycles, 2) improved software usage, reliability, and robustness, and 3)greater ease of readability and maintainability. In general the Sun Java conventions should be followed but here are several of the more important/common conventions.
All class names should be NamedLikeThis.
All variable names (primitives and objects) should be namedLikeThis.
All method names should be namedLikeThis().
All method names should be descriptive of what the method does.
All methods must have a return type (either a primitive or class) or
void if nothing is returned.
All class, method and variable declartions need to have the appropriate access modifier.
The public access modifier should be used for classes, global
constants, and publicly visible methods.
The protect access modifier should be used for internal variables
or methods that may need to be used by a subclass. Generally, for this class, this access modifier
does not need to be used.
The private access modifier should be used primarily for internal
variables.
Constants should be final and static in
addition to being public.
Methods and variables should be static if they are not instance
specific.
Member variables should generally have private access. The value
can be retrieved or modified through get and set methods. For example the variable
data would have methods getData() and setData(newValue).
Comments should be used to briefly describe what a method does, the purpose of a class or
to explain what potentially confusing code does. Here's a link to
javadoc tags.
// This is a single line comment.
/*
* This is a multiline comment.
*/
Note: This list may be added to later if needed.