Java Coding Conventions
...
Indentation
Please use 4 spaces per tab.
...
Setup your Java Indentation settings in Netbeans to look like this.
Naming
In general, abbreviations should not be used in naming.
Method Names
Methods should be named with a verb and a noun. The verb noun should be capitalized.
Please do not use underscores in Java names.
Here are examples of good method names.
No Formatcode |
---|
computeSum() getX() setY() |
Getters should start with get and setters should start with set. Method names
such as x() instead of getX() are ambiguous.
Variable Names
Variables should start with a lowercase letter. Subsequent words should be capitalized.
Here are examples of variable names.
No Formatcode |
---|
thetaIndex phiBins binValues |
...
For instance, this is a perfectly valid way of assigning a member variable that has the same name
as the method argument.
No Formatcode |
---|
void setFoo(int foo) { this.foo = foo; } |
Interfaces and Implementations
Java makes a distinction between interfaces, which have no method bodies, and implementations,
which are classes that may also be abstract. There is no distinction made in naming conventions
between abstract and non-abstract (concrete) classes.
...