Coding Standard and Style Guide - OttaboticsRobotRacing/MK2 GitHub Wiki

Coding Standard

Directory and File Structure

MK2 Repository

MK2/
  src/
  include/
  modules/
    <module name>/
      src/
      include/
      docs/
      test/
      res/
      Makefile
      module.mk
      README.md
  docs/
  res/
  Makefile
  README.md

MK2/src/

This directory will only store code for the core module. This will only be maintained by Jimmy.

MK2/include/

This directory will only store code for the core module. This will only be maintained by Jimmy.

MK2/modules/

This directory will contain directories containing the individual modules for MK2. Some examples are: sample, navigation, vision, utility, etc.

MK2/modules/<module name>/src/

This directory will contain source code, ie. .cpp files, for <module name>

MK2/modules/<module name>/include/

This directory will contain header files, ie. .hpp files, for <module name>

MK2/modules/<module name>/docs/

This directory will contain documentation for <module name>

MK2/modules/<module name>/test/

This directory will contain testing code for <module name>, i.e. test.cpp

MK2/modules/<module name>/res/

This directory will contain resource files for <module name>, i.e. sample and test images

MK2/modules/<module name>/Makefile

Makefile to compile <module name> separately from the core

MK2/modules/<module name>/module.mk

Makefile used to include this module when compiling the core

MK2/modules/<module name>/README.md

README for <module name>

MK2/docs/

This directory will contain documentation (generated by Doxygen).

MK2/res/

This directory will contain resource files for the core

MK2/Makefile

Makefile used to compile the core

MK2/README.md

README for the core

POC Repository

Create a new directory for each POC.

POC/
  <POC idea 1>/
    src/
    include/
    Makefile
    README.md
  <POC idea 2>/
  <POC idea 3>/

Naming Conventions

Refer to the Google Style Guide.

General

Names should be descriptive; avoid abbreviation.

Give as descriptive a name as possible, within reason. Do not worry about saving horizontal space as it is far more important to make your code immediately understandable by a new reader. Do not use abbreviations that are ambiguous or unfamiliar to readers outside your project, and do not abbreviate by deleting letters within a word.

File Names

Filenames should be all lowercase and can include dashes (-).

Type Names

Type names start with a capital letter and have a capital letter for each new word, with no underscores: MyExcitingClass, MyExcitingEnum.

Variable Names

The names of variables (including function parameters) and data members are all lowercase, with underscores between words. Data members of classes (but not structs) additionally have trailing underscores. For instance: a_local_variable, a_struct_data_member, a_class_data_member_.

Common Variable Names

Class Data Members

Data members of classes, both static and non-static, are named like ordinary nonmember variables, but with a trailing underscore.

Struct Data Members

Constant Names

Function Names

⚠️ **GitHub.com Fallback** ⚠️