⚡
Keyboard shortcut: Shift+Alt+F (Windows/Linux) or Shift+Option+F (Mac) autoformats the current file instantly. Run before every commit.
The Core Style Rules for VRC C++
Avoid
void intakefwd(){
intake.move(127);if(x>5)
{doSomething();}}
Prefer
void intakeForward() {
intake.move(127);
if (x > 5) {
doSomething();
}
}
Naming Conventions
- Functions —
camelCase starting with lowercase: intakeForward(), armGoTo(int pos)
- Constants —
ALL_CAPS_WITH_UNDERSCORES: MAX_ARM_HEIGHT, STALL_CURRENT_MA
- Variables —
camelCase: armTarget, isStalled, stallStartTime
- Classes/Enums —
PascalCase: IntakeState, ClawState
- Files — lowercase with hyphens or underscores:
intake.cpp, robot-config.cpp
Comment Rules
const int STALL_TIME_MS = 300;
const int STALL_TIME_MS = 300;
VS Code Autoformat Setup
Shift+Alt+FFormat current file (Windows/Linux)
Shift+⌥+FFormat current file (Mac)
Ctrl+Shift+POpen Command Palette → type "Format Document"
To enable format on save (recommended for team projects): open VS Code Settings, search for editor.formatOnSave, and enable it. Now every file is formatted automatically when you save — no manual step needed.
✅
Add a .clang-format file to your project root to enforce consistent brace and indentation style across all team members' VS Code setups. A minimal one: create .clang-format with content BasedOnStyle: Google. This applies Google’s C++ style guide, which is clean and well-suited to PROS projects.
ℹ️
Style is notebook evidence too. Screenshots of well-organized, consistently styled code with meaningful comments demonstrate software engineering discipline. Judges who look at code excerpts in engineering notebooks can tell the difference between a team that treats code as craft vs one that treats it as a necessary evil.
Code style is not cosmetic — it is information design. Research in software engineering consistently shows that code is read 10× more often than it is written. Naming is the primary documentation: armTargetPosition communicates intent; x does not. Technical debt is the accumulated cost of messy code: when you need to change something quickly at a competition, unreadable code costs time you do not have. Auto-formatting (Shift+Alt+F) enforces a consistent grammar — just as academic writing follows style guides, code follows formatting conventions.
🎤 Interview line: “We treat code style as engineering discipline. Consistent naming and formatting reduce cognitive load when debugging under pressure at a competition. We use .clang-format to enforce rules automatically — the same approach used in every professional software development environment.”
🔬 Check for Understanding
Why is chassis.pid_drive_set(intakeTriggerDistance, driveSpeed) better than chassis.pid_drive_set(d, s)?
It runs faster because named variables are cached
Single-letter variable names are reserved for math equations only
The descriptive names document intent — you can read the code without needing a comment to explain what d and s mean
There is no difference — compilers treat all variable names identically