aboutsummaryrefslogtreecommitdiff
path: root/doc/developer-notes.md
diff options
context:
space:
mode:
Diffstat (limited to 'doc/developer-notes.md')
-rw-r--r--doc/developer-notes.md44
1 files changed, 20 insertions, 24 deletions
diff --git a/doc/developer-notes.md b/doc/developer-notes.md
index b00cceb987..1f237b750e 100644
--- a/doc/developer-notes.md
+++ b/doc/developer-notes.md
@@ -50,7 +50,7 @@ Do not submit patches solely to modify the style of existing code.
[src/.clang-format](/src/.clang-format). You can use the provided
[clang-format-diff script](/contrib/devtools/README.md#clang-format-diffpy)
tool to clean up patches automatically before submission.
- - Braces on new lines for namespaces, classes, functions, methods.
+ - Braces on new lines for classes, functions, methods.
- Braces on the same line for everything else.
- 4 space indentation (no tabs) for every block except namespaces.
- No indentation for `public`/`protected`/`private` or for `namespace`.
@@ -72,7 +72,8 @@ code.
- Class names, function names and method names are UpperCamelCase
(PascalCase). Do not prefix class names with `C`.
- Test suite naming convention: The Boost test suite in file
- `src/test/foo_tests.cpp` should be named `foo_tests`.
+ `src/test/foo_tests.cpp` should be named `foo_tests`. Test suite names
+ must be unique.
- **Miscellaneous**
- `++i` is preferred over `i++`.
@@ -84,8 +85,7 @@ Block style example:
```c++
int g_count = 0;
-namespace foo
-{
+namespace foo {
class Class
{
std::string m_name;
@@ -450,12 +450,21 @@ C++ data structures
- Vector bounds checking is only enabled in debug mode. Do not rely on it
-- Make sure that constructors initialize all fields. If this is skipped for a
- good reason (i.e., optimization on the critical path), add an explicit
- comment about this
+- Initialize all non-static class members where they are defined.
+ If this is skipped for a good reason (i.e., optimization on the critical
+ path), add an explicit comment about this
- *Rationale*: Ensure determinism by avoiding accidental use of uninitialized
values. Also, static analyzers balk about this.
+ Initializing the members in the declaration makes it easy to
+ spot uninitialized ones.
+
+```cpp
+class A
+{
+ uint32_t m_count{0};
+}
+```
- By default, declare single-argument constructors `explicit`.
@@ -474,18 +483,6 @@ C++ data structures
- *Rationale*: Easier to understand what is happening, thus easier to spot mistakes, even for those
that are not language lawyers
-- Initialize all non-static class members where they are defined
-
- - *Rationale*: Initializing the members in the declaration makes it easy to spot uninitialized ones,
- and avoids accidentally reading uninitialized memory
-
-```cpp
-class A
-{
- uint32_t m_count{0};
-}
-```
-
Strings and formatting
------------------------
@@ -571,8 +568,7 @@ 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.
+ definitions from, even if those headers are already included indirectly through other headers.
- *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
@@ -588,11 +584,11 @@ Source code organization
```c++
namespace mynamespace {
- ...
+...
} // namespace mynamespace
namespace {
- ...
+...
} // namespace
```
@@ -626,7 +622,7 @@ GUI
holds: try to not directly access core data structures from Views.
- Avoid adding slow or blocking code in the GUI thread. In particular do not
- add new `interface::Node` and `interface::Wallet` method calls, even if they
+ add new `interfaces::Node` and `interfaces::Wallet` method calls, even if they
may be fast now, in case they are changed to lock or communicate across
processes in the future.