Coding Standards

General

  • Use spaces not tabs.

  • Indents are 4 spaces.

  • Document and comment your code. If it is non-obvious what a piece of code is doing, it should be documented clearly.

  • If possible, don't copy and paste code between files - code reuse is much quicker and more practical.

  • All filenames are to be lowercase, alphanumeric with hyphens or underscores (hyphens preferred, except for Python modules where underscores are necessary).

    • This means no filenames with spaces or brackets (lest the fury of a thousand suns, i.e. others who live in the terminal, rain down upon you).

    • Use hyphens or underscores to separate words.

  • Team members should avoid working on top of other people's branches. i.e. everyone should only branch from the main branch.

Python

Use Black

Naming:

  • Class names use PascalCase.

  • Function names use snake_case, except for when implementing WPILib interfaces (which use camelCase).

    • (This is potentially up for discussion.)

  • Variable names use snake_case.

  • Global "constants" in ALL_UPPERCASE.

  • Global "constants" declared at the top of the file or top level of a relevant class.

JavaScript

We don't have our own style guide here. We do like Airbnb's JS style guide though.

HTML

2 space indents are probably a good idea — HTML is very nesting-heavy…

C/C++

  • Classes declared in header, functions defined in cpp file.

  • Classes use CamelCase.

  • Functions use lowerLeadingCamelCase.

  • Variables use lowercase_with_underscores.

  • Symbolic constants in ALLUPPERCASE.

  • Symbolic constants in the header file.