From e4f0a95af8ce6cfb71602c5f5e437ab68dd582ec Mon Sep 17 00:00:00 2001 From: JF Date: Sun, 4 Oct 2020 12:52:48 +0200 Subject: [PATCH] Add coding conventions in contribute.md --- doc/contribute.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/doc/contribute.md b/doc/contribute.md index 53c6ac06..40441cd2 100644 --- a/doc/contribute.md +++ b/doc/contribute.md @@ -21,4 +21,24 @@ Then, you can submit a pull-request for review. Try to describe your pull reques Other contributors can post comments about the pull request, maybe ask for more info or adjustements in the code. -Once the pull request is reviewed an accepted, it'll be merge in **develop** and will be released in the next release version of the firmware. \ No newline at end of file +Once the pull request is reviewed an accepted, it'll be merge in **develop** and will be released in the next release version of the firmware. + +# Coding convention +## Language +The language of this project is **C++**, and all new code must be written in C++. (Modern) C++ provides a lot of useful tools and functionalities that are beneficial for embedded software development like `constexpr`, `template` and anything that provides zero-cost abstraction. + +It's OK to include C code if this code comes from another library like FreeRTOS, NimBLE, LVGL or the NRF-SDK. + +## Coding style +The most important rule to follow is to try to keep the code as easy to read and maintain as possible. + + - **Identation** : 2 spaces, no tabulation + - **Opening brace** at the end of the line + - **Naming** : Choose self-describing variable name + - **class** : PascalCase + - **namespace** : PascalCase + - **variable** : camelCase, **no** prefix/suffix ('_', 'm_',...) for class members + - **Include guard** : `#pragma once` (no `#ifdef __MODULE__ / #define __MODULE__ / #endif`) + - **Includes** : + - files from the project : `#include "relative/path/to/the/file.h"` + - external files and std : `#include ` \ No newline at end of file