C2.6 Programming Practices
Style
Style Guide
Package Names
“It should be an in lowercase ASCII letter such as java, lang. If the name contains multiple words, it should be separated by dots (.) such as java.util, java. lang.”
Examples:
package frc.robot;
package frc.robot.commands.ballpath;”
Class and Interface name:
“It should start with the uppercase letter. Use words, instead of acronyms. “
It should be a noun such Robot, Climber, ShuffleboardTab, etc. Use words, instead of acronyms
Examples:
class Robot
class Swerve
class Launcher extends SubsystemBase
Method name
“Usually, the method name should either be a verb or verb-noun combination starting with the lower letter. If it contains multiple words then every inner word should start with uppercase.”
Examples:
public void periodic()
public void setVelocity( double velocity)
public static Command getAutonomousCommand()
Variable name:
“i) Instance variable: Usually variable name should be a noun starting with a lowercase letter. If it contains multiple words then every inner word should start with uppercase.”
Examples: motor; speed; velocityRPM;
“ii) Constants (final variables):- Usually, a constant name should be a noun. It should contain the only uppercase If it contains multiple words then words are separated with the ( _ ) underscore symbol. Usually, we declare constants with public static and final modifiers.”
Examples:- CAN_CONFIG_TIMEOUT, MIN_BATTERY_VOLTAGE, PIGEON_ID
Variable name:
“iii) boolean variables:- It uses “is” as a prefix before the variable name. Negated boolean variable names must be avoided.”
Example:- boolean isAngleEnableCurrentLimit boolean isDriveMotorInvert
Don’t Use:- boolean isNotDriveMotorInvert
“iv) Private variable:- It uses underscore ( _ ) at end of the variable name.”
Example:- private double rpm_; private double kP_, kI_, kD_, kF_;
Importing Classes
“ Imported classes must always be listed explicitly. Importing classes explicitly gives an excellent documentation value for the class at hand and makes the class easier to comprehend and maintain.”
Example:- import frc.robot.commands.ResetGyro; import frc.robot.commands.swerve.TurnToAngle;
Don’t Use:- import frc.robot.commands.*;
Method/Class Modifiers
“Modifiers should be given in the following order:
<access> static abstract synchronized <unusual> final native
The <access> modifier (if present) must be the first modifier.”
Examples:- public static XboxGamepad driver
Don’t Use:- static public XboxGamepad operator
Git / Github
Git VScode Integration
Github Pull Requests and Issues Extension
Github Desktop App
Git Branches
Pull Requests
Github Tags/Releases
Git Tips
Folders
Top Level Folders
Lib
robot
Classes
Subsystems
Subsystem Creation
Subsystem - Default Commands
Constants
Commands