Standards for how we should format code. Please discus on discord or with issues.
Find a file
2025-08-22 17:03:07 -07:00
README.md Update README.md 2025-08-22 17:03:07 -07:00

Code Standards

Standards for how we should format code. Please discuss on discord or with issues.

Article on cases.

  1. 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;
        ...
    }
   ...
}
  1. Subsystems should follow this structure:
    Imports (remember to run Alt+Shift+O to format imports),
    Defines,
    Subsystem definition function,
    Periodic,
    Any other functions, (Optionally: a UpdateDash() function to publish to Smart dashboard)

  2. 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.

  3. Please run format document often! You can do this by pressing Ctrl+Shift+I.

  4. You should proceed definitions in the start of classes with an extra line. ex:

class Foo {
        <--- Extra line here!
    string bar = "Hello, world!";
}
  1. Non-constant variable names should be in camelCase.

  2. Class names should be in PascalCase.

  3. 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.)

  1. Keep commit messages sane.