Style Guide Proposal

File naming

File names should be prefixed with the Subsystem, and then a descriptive name in Pascal Case or all uppercase for specific nouns.

LOS_DRIVER_BMX160.cpp AM_StateClasses.cpp AM_Interface.cpp LOS_Link.cpp LOS_CORE_i2c.cpp SF_MAHRS.cpp

 

Variables

variables should be written using camel case.

most languages have camel case as part of their standards, including C and C++ in none safety critical application, but barr cannot properly explain why camel case is objectively unsafe. I would also make the argument that most people that join this team with programming experience most likely have experience reading camel case.

int youAreReadingThis = 0; int youAreReadingThis{0}; bool niceThanksForReading = false; bool niceThanksForReading{false}; double thisIsSuperFun = 0.0f;

Constants

should be named using all caps and snake case

const int YOU_ARE_READING_THIS{0}; constexpr bool IS_FIXED_WING{false};

Declaring Variables on the Same Line

should be based on the number of characters, not the number of variables, but I think most of our code doesn't declare variables on the same line anyway so this isnt that important.

Breaks

if the loop is simple enough, I don't see a point in boolean flags. Sometimes Its easier to just look for the break statement than to look for what boolean is in the for loop condition, and where its being set. I think this should be done case by case. If the MIRA-C guide says no break statements, then I wont argue with it.

Functions

Naming and Brackets

brackets are fine, I think public functions should be upper cased personally, and pascal case.

In general, functions should be named differently if they're going to be private vs public, dart uses _functionName to denote private functions, go uses upper case / lower case, etc.

 

Member Variables

Non-static member variables should use snake case.

Constants should use camel case with a k as the first character.

Static variables should use snake case, but have a _ as the first character.

these feel backwards. variables should all use some form of camel case. If you want to prepend an s to static, that works. Make sure to reference all members properly in functions though, (a lot of our code, even the old code we inherited, doesnt reference class variables properly.