diff options
Diffstat (limited to 'doc/developer-notes.md')
-rw-r--r-- | doc/developer-notes.md | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/doc/developer-notes.md b/doc/developer-notes.md index ec6abda91e..81bdcc9fdb 100644 --- a/doc/developer-notes.md +++ b/doc/developer-notes.md @@ -68,7 +68,7 @@ public: return true; } } -} +} // namespace foo ``` Doxygen comments @@ -287,7 +287,7 @@ General C++ - Assertions should not have side-effects - - *Rationale*: Even though the source code is set to to refuse to compile + - *Rationale*: Even though the source code is set to refuse to compile with assertions disabled, having side-effects in assertions is unexpected and makes the code harder to understand @@ -425,11 +425,34 @@ Source code organization - *Rationale*: Shorter and simpler header files are easier to read, and reduce compile time +- Every `.cpp` and `.h` file should `#include` every header file it directly uses classes, functions or other + definitions from, even if those headers are already included indirectly through other headers. One exception + is that a `.cpp` file does not need to re-include the includes already included in its corresponding `.h` file. + + - *Rationale*: Excluding headers because they are already indirectly included results in compilation + failures when those indirect dependencies change. Furthermore, it obscures what the real code + dependencies are. + - Don't import anything into the global namespace (`using namespace ...`). Use fully specified types such as `std::string`. - *Rationale*: Avoids symbol conflicts +- Terminate namespaces with a comment (`// namespace mynamespace`). The comment + should be placed on the same line as the brace closing the namespace, e.g. + +```c++ +namespace mynamespace { + ... +} // namespace mynamespace + +namespace { + ... +} // namespace +``` + + - *Rationale*: Avoids confusion about the namespace context + GUI ----- |