Eclipse/Sun code conventions with
- Spaces only
- Indentation size 4 spaces
- Maximum line width 160
- Maximum width for comments 120
- No indent of Javadoc tags
- No newline after @param tags
See also: https://github.com/eclipse-ee4j/ee4j/tree/master/codestyle
@param a The first parameter. For an optimum result, this should be an odd
number between 0 and 100.
Based on the advice from Uncle Bob's Clean Code, specifically:
- No cryptic abbreviations like c, ta, rx, ct, except for the well-established i and j in loops
- No variable names like ret, rvalue, result etc for variables that are returned from methods. Instead, they should be named after what they actually return.
For example:
Bad:
public Permissions getCallerPermission(....) {
Permissions rvalue;
// ton of code
return rvalue;
}
Good:
public Permissions getCallerPermissions(....) {
Permissions callerPermissions;
// ton of code
return callerPermissions;
}
- No Hungarian variations for collections like usrLst, usArray, arrUsers, UserCol, etc, and no such variation for elements of the collection like el, elm, usrEl, userElem, currentUsr, curUser, userCr, etc. Omit the Hungarian and use the element type name directly and the plural of that for the collection.
For example:
Bad:
for (User curUsr : colUser) {
...
}
Good:
for (User user : users) {
...
}
For example:
Bad:
public void foo(Bar bar) {
if (bar != null) {
// lots of code here
} else {
throw new IllegalStateException("Bar should not be null");
}
}
Good:
public void foo(Bar bar) {
if (bar == null) {
throw new IllegalStateException("Bar should not be null");
}
// lots of code here
}
For example:
Bad:
if (foo == something) {
return somethingFoo;
} else if (foo == somethingElse) {
return somethingElseFoo;
}
Good:
if (foo == something) {
return somethingFoo;
}
if (foo == somethingElse) {
return somethingElseFoo;
}
For example:
Bad:
public class SomeClass {
private int someNumber = 0;
private Foo someFoo = null;
private boolean isFoo = false;
}
Good:
public class SomeClass {
private int someNumber;
private Foo someFoo;
private boolean isFoo;
}
For example:
Bad:
public interface MyInterface {
public void MyMethod();
}
Good:
public interface MyInterface {
void MyMethod();
}
Bad:
public Foo getFoo() {
return this.foo;
}
Good:
public Foo getFoo() {
return foo;
}
For example:
Bad
return (1);
Good
return 1;