|
|
Coding Guidelines
The following coding guidelines are considered to be the fundamental
rules to be followed when developing code for the FIPA-OS codebase:
- Bracketing should be on new lines. e.g:
public void method1()
{
....
}
Rationale: There seems to be a consensus that code is more readable
if opening and closing brackets "match".
- Instance variables are prefixed with a single underscore. e.g:
private Object _field1;
Rationale: A method is needed to distinguish instance variables
from local variables. The underscore is an "ugly" feature to remind
people about the importance of instance variables (as suggest by Doug
Lea's draft coding stds).
- Static variables are prefixed by two underscores. e.g:
private static Object __field1;
Rationale: Similar to point 2, this distinguishes static variables
from other types of variables straight away - it avoids having to search
through the source to discover the particular type of variable it is.
- Class Names should begin with a Capital letter, with the first letter
of every word being capitalised too. e.g:
public class DirectoryFacilitator
Rationale: This conforms to the Sun Microsystems coding std.
- Method Names begin with a lower case letter, the first letter of
every word afterwards being capitalised. e.g:
public void aMethodNameThatConforms()
Rationale: Sun Microsystems coding std.
- All variable names will be in lower case with words being separated
by underscores. e.g:
public void _field1_is_an_example_name;
Rationale: This makes it quicker to identify variables from method
names.
- Constants are fully capitalised. e.g:
public static final int A_CONSTANT
= 1;
Rationale: It's easier to identify constants this way.
|
|
|
|