Skip to content

Latest commit

 

History

History
38 lines (31 loc) · 1.23 KB

styleguide.md

File metadata and controls

38 lines (31 loc) · 1.23 KB

Style Guide

This is just a proposal so far

Naming conventions

  • functions, methods and variables: lowercase_with_underscores
  • enums, structs and typedefs: _t suffix
  • enum members, #define members: ALLCAPS_WITH_UNDERSCORES
  • classes: CamelCase
  • properties: dromedaryCase

Whitespace

  • indent with 4 spaces
  • namespaces are not indented
  • public: and protected: inside a class are indented 1 space
  • single space around operators
  • single newline between function definitions
  • no spaces directly inside parenteses, single space outside of them
  • no trailing whitespace

Nesting

  • opening accolade on same line as function definition / control statement
  • closing accolade on its own line except in case of an else statement

Comments

  • copyright string at top of each file: Copyright 2015 Stichting Humanity4all
  • comment goes before code, not after it
  • strive to avoid inline comments
  • prefer /* */ style over //

Other formatting

  • line length of 80
  • use a header guard in header files -> SRC_FILENAME_H_ if file is in the src directory.

Design decisions

  • separate hardware interface and application logic as much as possible
  • write unit tests for your code where possible
  • no memory allocation outside of the setup function