| README.md | ||
Code Standards
Standards for how we should format code. Please discuss on discord or with issues.
Article on cases.
- Constants should always be ALL CAPS in snake_case. Constants should come from a central constants file, divided into subclasses. ex:
public class Constants {
public class Robot {
public static final double COMPENSATED_VOLTAGE = 10.0;
}
public class Identifiers {
public static final int CONTROLLER_PRIMARY_PORT = 0;
public static final int CONTROLLER_SECONDARY_PORT = 1;
public static final int LAUNCHER_MOTOR_RIGHT = 9;
public static final int LAUNCHER_MOTOR_LEFT = 10;
...
}
...
}
-
Subsystems should follow this structure:
Imports (remember to run Alt+Shift+O to format imports),
Defines,
Subsystem definition function,
Periodic,
Any other functions, (Optionally: aUpdateDash()function to publish to Smart dashboard) -
PID values should always be defined in constants! It should also always be called simply "P", "I", "D" ("T"), NOT "kP", "kI", etc... k (meaning konstant I suppose) as a header is a really outdated convention that WPILib follows for some reason.
-
Please run format document often! You can do this by pressing Ctrl+Shift+I.
-
You should proceed definitions in the start of classes with an extra line. ex:
class Foo {
<--- Extra line here!
string bar = "Hello, world!";
}
-
Non-constant variable names should be in camelCase.
-
Class names should be in PascalCase.
-
Prefix classes and functions with a short comment discription of what they do. ex:
/**
* Initialization that applies to autonomous and teleop.
*/
private void generalInit() {
...
}
(Tip: ChatGPT can generaly generate decent documentation.)
- Keep commit messages sane.