-
Notifications
You must be signed in to change notification settings - Fork 1
Team Style Guide
-
All variables are to be camel case - start with lowercase, then capitalize the first letter of each word.
- Example:
int camelCase;
- Example:
-
All enumerated values are to be pascal case - the first letter of every word is capitalized.
- Example:
fieldPos = Center;
- Example:
-
Words in variable names may be abbreviated unless it causes conflict with understanding its purpose.
-
Acceptable:
Spark left1
(Given that there is no other first left spark on the robot) -
Acceptable:
Spark l1
(Using L and R for left and right is an acceptable abbreviation) -
Acceptable:
FieldPosition fieldPos
(Pos is a good abbreviation for position) -
Unacceptable:
FieldPosition fPos
(When the variable is by itself, it is unclear what 'f' stands for)
-
-
Booleans are not to be named "is..."
-
Acceptable:
bool leftSwitch
-
Unacceptable:
bool isSwitchLeft
-
-
All structures and objects are to be named in pascal case.
-
Example:
class Robot
-
Example:
enum FieldPosition
-
-
Functions are to be named in pascal case.
- Example:
void TankDrive();
- Example:
-
Open curly braces are to be inline and one space away from the end.
-
Close curly braces are to be on a new line.
- Example:
void TankDrive() {
// Some stuff here
}
-
There is to be a space surrounding every operator.
-
Acceptable:
someVar == someVal
-
Acceptable:
someVar = 1;
-
Unacceptable:
someVar=1;
-
-
There is to be a space between
if
(orelse if
) and its condition.-
Acceptable:
if (someCondition) {
-
Unacceptable:
if(someCondition) {
-
-
else
andelse if
are to be on the subsequent line below the closing brace of the preceding statement.- Example:
if (someVal == 1) {
// Some stuff here
}
else if (someVal == 2) {
// Some different stuff here
}
else {
// Some completely different stuff here
}
-
All constants are to be declared and defined in the source file.
-
All constants are to be declared and defined in the same line.
-
All constants are to be grouped as follows:
-
All representing different ports of the same type are to be on subsequent lines in numerical order.
-
There is to be one empty line to separate different port types.
-
Port types are to be declared in alphabetical order.
-
-
Example:
const int pwm0 = 0;
const int pwm1 = 1;
const int pwm2 = 2;
const int usb0 = 0;
const int usb1 = 1;
-
To be used as explanations or labels for existing code.
-
As an explanation:
-
The comment is to be inline.
-
The comment is to be one space away from the end of the code in that line.
-
Example:
void Robot::TeleopInit() { // Runs at start of teleoperated phase, only once
-
-
As a label:
-
The comment is to be on the line directly above the code it labels.
-
The comment is to have one empty line above it.
-
Example:
-
// Values and Structures
bool leftswitch;
bool leftscale;
-
All messages are to be in the past tense.
- Example:
Added some stuff
- Example:
- Nah