Skip to content

Naming Conventions

OneLemonyBoi edited this page Mar 11, 2023 · 2 revisions

Classes

Classes in the codebase use UpperCamelCase or PascalCase.

class HelloWorld {}

Each type of class has a different word structure:

Subsystems

For subsystems, names should be concise and have a max of 3 words, like VisionSub, ArmSub, ClawSub, etc. All subsystems need "Sub" appended at the end of the concise class name.

Commands

Command class names should be long and descriptive to allow for ultimate readability. Long names are preferred due to the lack of new declarations or use in non RobotContainer files. All commands need "Cmd" appended at the end of the name.

Utility

Utility class names should be concise and have a max of 2 words. All utility classes need "Util" appended at the end of the name.

Methods

Methods need to be as short as possible, but not too short that it becomes hard to understand their purpose. Shortening words like "arbitrary" -> "arb" should not be done, but shortening words with common abbreviations like "Feed Forward" -> "FF" is fine.

Motors

Motor names need to describe the purpose of the motor and should ideally be under 3 words. Motors should have a shortened class name prefixed to them and "Motor" as a suffix. If a group of motors is being run synchronously, the main motor should be suffixed with "A" and the next motors should follow the alphabet. A couple of examples are ArmCascadeMotor, ArmJointMotorA, ArmJointMotorB, etc.

Buttons and Sensors

Button variable names need to be as short as possible, but not too short that it becomes hard to understand their purpose. Shortening words like "arbitrary" -> "arb" should not be done, but shortening words with common abbreviations like "Feed Forward" -> "FF" is fine.

Important Information!

Google Java Style Guide

WPILib Wiki

Clone this wiki locally