Tab size
The tab size should be set to 2 so that 1 tab suffices to indent a block of code. Also let your editor replace tabs by spaces.
Code blocks
As said above, we use 1 tab to indent a block of code. The curly brace at the start of a block should not be on a new line and should be preceeded by exactly 1 space.
public void foo() {
bar();
}
Exception clauses
The exception clause of a method should contain all exceptions that can be thrown by that method, including runtime exceptions (and excluding errors).
Names of variables
Variables should have meaningful names if possible. An exception to this rule are counters, for which the names i,j,... are clear enough.
The name of a variable should start with a small letter, and every word in the name (except the first one of course) should start with a capital letter.
Names of instance variables
The names of instance variables should start with a _ or a $ (although Sun does not recommend the last one). We prefer a $, but since the use of _ is so general, we're not going to ask others to adhere to that.
Names of constants
Constants are of course static and final variables. The name of a constant should only contains capital letters, and no $ or _ at the start. A _ should seperate different words in the name.
Names of methods
Methods should always have meaningful and short names because they form the interface to the third party programmer. Providing a meaningful is more important that providing a short name, because they make the code of the third party programmer easier to understand.
The name of a method should start with a small letter. All words in the name (except the first one) start with a capital letter.
|