Skip to content

Coding guideline#228

Open
BlueAndi wants to merge 2 commits intodevelopfrom
feature/codingGuideline
Open

Coding guideline#228
BlueAndi wants to merge 2 commits intodevelopfrom
feature/codingGuideline

Conversation

@BlueAndi
Copy link
Owner

@BlueAndi BlueAndi commented Mar 6, 2026

@BlueAndi BlueAndi requested a review from nhjschulz March 6, 2026 12:46
Copy link
Collaborator

@nhjschulz nhjschulz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments, mostly subjective as this is style guide related. Feel free to reject if you disagree.

| Private member variable | `m_` prefix + camelCase | `m_isActive`, `m_duration` |
| Constant / `static const` member | `UPPER_SNAKE_CASE` | `MIN_BATTERY_LEVEL`, `SEND_WAYPOINT_TIMER_INTERVAL` |
| File-scope static variable | `g` prefix + camelCase | `gLogSinkSerial` |
| Macro parameter | double-underscore prefix | `SIMPLE_TIMER_SECONDS(__timeInS)` |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this already used ? Dunder prefix is reserved to compiler/runtime.

| Macro parameter | double-underscore prefix | `SIMPLE_TIMER_SECONDS(__timeInS)` |
| Enum value | `UPPER_SNAKE_CASE` | `CMD_GET_MAX_SPEED`, `CMD_NONE` |

Use `uint8_t`, `uint16_t`, `uint32_t` etc. for sized integer types. Append `U` to unsigned integer literals (`50U`, `1000U`).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it simpler to refer to stdint.h base type usage.


---

## Headers
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should better move up to appear right after (or before) cpp skeleton.

Include order (within a file):
1. Own header (`"App.h"`)
2. Project headers (`<Board.h>`, `<Logging.h>`)
3. Third-party / Arduino headers (`<ArduinoJson.h>`)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std headers ?


Template/header-only implementations use `.hpp`, all others use `.h` / `.cpp`.

Include order (within a file):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may make sense to distinguish header and cpp usages here.
i.e a header should only include the minimum to allow compilation, not everything its module needs in implementation.


---

## Patterns
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for me such patterns are not desirable in a style guide. A singleton pattern has a lot more dependencies and quirks than style.
I also don't get the fous for "final" for concrete states. Better would be a rule when to apply final (and when not).


## Parameters

Pass non-trivial input arguments as `const` reference; output arguments as non-const reference:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any rule regarding pointer passing ? References are not working if a i nput/output is optional, i.e. may be a nullptr.

Format table.
Remove closing header guard in example.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants