aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2021-09-06 14:14:04 +0200
committerMarcoFalke <falke.marco@gmail.com>2021-09-06 14:14:22 +0200
commit92aad5303b9b96c46015156b5dc96b48e9e7bc76 (patch)
treefffeff904f59d7b7f57775c4d695bc61bb5f0bd0 /doc
parenta8fdfea77b0cdfcbc406558435968c1b801a5fdd (diff)
parent77f37f58ad2f349cecb2eda28b415267d3d7d76e (diff)
Merge bitcoin/bitcoin#21930: doc: update enumerator naming in developer notes
77f37f58ad2f349cecb2eda28b415267d3d7d76e doc: update enum naming in developer notes (Jon Atack) Pull request description: Per our current doc, the general rule is we follow the C++ Core Guidelines, which for enumerator naming stipulate: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Renum-caps ``` Don’t use ALL_CAPS for enumerators Reason: Avoid clashes with macros. ``` but our examples (and often, codebase) are contradictory to it (and perhaps to common usage), which can be confusing when a contributor needs to choose a style to use. This patch: - updates the enumerator examples to snake_case per CPP Core Guidelines - clarifies for contributors that in this project enumerators may be snake_case, PascalCase or ALL_CAPS, and to use what seems appropriate. ACKs for top commit: practicalswift: cr ACK 77f37f58ad2f349cecb2eda28b415267d3d7d76e ryanofsky: ACK 77f37f58ad2f349cecb2eda28b415267d3d7d76e. I think this is good because it modernizes the example and clarifies current conventions. promag: ACK 77f37f58ad2f349cecb2eda28b415267d3d7d76e. Tree-SHA512: 7facc607fe5e1abab0f635864340143f13c2e4bb074eb17eac7d829dcd0cf244c5c617fc49d35e8774e8af1fa1205eeebe0cca81f538a2a61f6a7ba200878bc6
Diffstat (limited to 'doc')
-rw-r--r--doc/developer-notes.md20
1 files changed, 12 insertions, 8 deletions
diff --git a/doc/developer-notes.md b/doc/developer-notes.md
index 583c50a763..3e13adeec0 100644
--- a/doc/developer-notes.md
+++ b/doc/developer-notes.md
@@ -89,6 +89,10 @@ code.
- Class member variables have a `m_` prefix.
- Global variables have a `g_` prefix.
- Constant names are all uppercase, and use `_` to separate words.
+ - Enumerator constants may be `snake_case`, `PascalCase` or `ALL_CAPS`.
+ This is a more tolerant policy than the [C++ Core
+ Guidelines](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Renum-caps),
+ which recommend using `snake_case`. Please use what seems appropriate.
- 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
@@ -669,19 +673,19 @@ Foo(vec);
```cpp
enum class Tabs {
- INFO,
- CONSOLE,
- GRAPH,
- PEERS
+ info,
+ console,
+ network_graph,
+ peers
};
int GetInt(Tabs tab)
{
switch (tab) {
- case Tabs::INFO: return 0;
- case Tabs::CONSOLE: return 1;
- case Tabs::GRAPH: return 2;
- case Tabs::PEERS: return 3;
+ case Tabs::info: return 0;
+ case Tabs::console: return 1;
+ case Tabs::network_graph: return 2;
+ case Tabs::peers: return 3;
} // no default case, so the compiler can warn about missing cases
assert(false);
}