This page documents good practices for how to format and style our C++ code
- File names are in Pascal Case (
PascalCase) - Function names are in Pascal Case (
PascalCase) - Classes are in Pascal Case (
PascalCase) - Constants should be in capitalized snake case (
CAPITALIZED_SNAKE_CASE) - Variables are in lower snake case (
lower_snake_case) - Namespaces are Camel Case and one word (
Namespace)
- Indentation is 4 spaces
- Private variables and functions begin with an underscore (
_lower_snake_case) - Comments should have a space between the double forward slashes (
// This is a comment) - Class and function contents' corresponding curly brackets should have a space before them
class Driver_Interface { -- snip -- }; void DrivetrainSubsystem::Periodic() { -- snip -- }
- Functions should never be condensed to one line
- Corresponding
.cppand.hfiles should have the same name - Subsystem files are named
<subsystem name>Subsystem - Commands are separated into
/autonand/teleopfolders- The names should be either
Auton<command name>orTeleop<command name>
- The names should be either
- Namespaces shouldn't be used in
.hfiles, but they can be used in.cppfiles - Don't use
@pragma once, instead use#ifndef <capitalized filename and file extension>#ifndef FILENAME_H #define FILENAME_H -- snip -- #endif