-
Notifications
You must be signed in to change notification settings - Fork 1
coding conventions
Each file must be named after the case sensitive name of the class it contains.
Each file can contain at most one outer class, interface of enumeration.
Each class name must start with an upper case character. The rest of the name is written in camelCase.
example: ThisIsAClassName
Each method must start with a lower case character. The rest of the name is written in camelCase.
example: thisIsAMethodName()
Each attribute must start with an underscore (_). The rest of the name is written in camelCase, starting with a lower case character.
example: _thisIsAnAttributeName
The name must be written in camelCase starting with a lower case character.
example: thisIsAVariableName
The class containing the enumeration must respect the class naming convention. The item in the class must be all upper case separated by underscores (_).
example: TypePrefix.THIS_IS_A_VALUE
Acronymes in names must respect the naming convention defined here, even if it is not the way it is normally written.
example: HttpCollection (instead of HTTPCollection)
Indentation must use tabs.
This is the design prefered:
class MyClass {
int _myAttribute;
public void myFunction(int parameter) {
switch(parameter) {
case 0: {
_myAttribute = 10;
}
break;
case 1: {
_myAttribute = 15;
}
break;
default: {
_myAttribute = 0;
}
break;
}
}
}The @param must be filled when a parameter is given to a method. The @return must be filled when a method returns a value. Each class, enumeration and method must have at least a brief explanation of their purpose.
Example:
/**
* This class contains a collection of ordered integers
*/
public class OrderedSet {
/**
* Check if a given value exists in the set
* @param value The value to search for in the set
* @return True if the value have been found, false otherwise
*/
public boolean exists(int value) {
// ...
}
}Never use spaces between a method's or language construction's name and the parenthesis
Example : if(value && otherValue)
Always use spaces between an operator and its operands (except for unary operators)
Example : int value = anotherValue && !check