-
Notifications
You must be signed in to change notification settings - Fork 0
Formatting
Austen Adler edited this page Mar 22, 2015
·
8 revisions
DentMain
DentDrive
GetNumber()
float potValue, currentSpeedValue //for private, public, or global variables
int i, j, k //for iterations
int i,j,currentSpeedValue;
Good:
int robotDriveSpeed;
int robotDriveSpeed2,robotDriveSpeed3;
Bad:
int robot_drive_speed;
int robot_Drive_Speed_2;
int Robot_Drive_Speed_3;
Good:
for(int i=0;i<100;i++){
//code
} //Never use variable i again
Bad:
int i;
for(i=0;i<100;i++){
//code
} //Never use variable i again
Good:
bool GetDriveSpeed();
void SetDriveSpeed();
int CalculateAngle(int sensor=2);
Bad:
bool ReturnDriveSpeed();
void PutDriveSpeed();
Formatting rules should be inherited from 1TBS
Brackets, curly braces, parentheses, variables, and functions should not contain extra padding
Two spaces used per indentation level
No space before, one space after the inheritance colon
One space after commas
All floating point numbers should be declared in decimal notation
Good:
float number = 0.3;
double anotherNumber = 5.0;
Bad:
float number = .3;
double anotherNumber = 5;
No trailing whitespace
Good:
bool testDrive, anotherBool;
for(int i = 0; i < 10; i++){
statements;
}
bool notTrue = false;
if(notTrue){
statement1;
}else{
statement2;
}
class Autonomous: CommandGroup(){
}
Bad:
bool testDrive,anotherBool;
for ( int i=0 ;i<10 ;i++) {
statements;
}
bool notTrue=false;
if ( notTrue == false )
{
statement1;
}
else
{
statement2;
}
class Autonomous : CommandGroup () {
}
Comments can be written in the document, but must be necessary. Comments can also be included as TODOs:
Good:
//currentAngle must be lower than 100
//TODO: Implement this
void shootRobot(int currentAngle);
Bad:
//Drives robot
//We should implement this
void driveRobot();
Vim marker comments can be included, but must contain the name of the function or have a short description of the function. The marker text should go before the marker:
Good:
//Declerations{{{
int testMode=0;
int otherMode=2;
}}}
//Drives Robot{{{
void driveRobot(){
//Code
}
//}}}
//driveRobot{{{
void driveRobot(){
//Code
}
//}}}
Bad:
//{{{Drives Robot
void driveRobot(){
//Code
}
//}}}
//This function activates the driving capabilities of the robot by providing electricity to the motors causing a rotation of the wheels that propels the robot forward, backward, or in any other direction{{{
void driveRobot(){
//Code
}
//}}}
Git projects should follow the Git Flow model
Branches use lowercase letters separated by dashes
Feature, patch, or tag branches begin with feature/
, patch/
, or tag/
Good:
feature/auto-power
develop
master
tag/v1.0
Bad:
feature/NewBranch
new_branch
new-branch-feature