Skip to content
This repository was archived by the owner on Oct 28, 2021. It is now read-only.

Commit d07b67b

Browse files
authored
Added some more backticks
1 parent 859ba13 commit d07b67b

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

CODING_STYLE.md

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ Use clang-format tool to format your changes, see [CONTRIBUTING](CONTRIBUTING.md
77

88
## Namespaces
99

10-
1. No "using namespace" declarations in header files.
10+
1. No `using namespace` declarations in header files.
1111
2. All symbols should be declared in a namespace except for final applications.
1212
3. Preprocessor symbols should be prefixed with the namespace in all-caps and an underscore.
1313

14+
```cpp
1415
// WRONG:
1516
#include <cassert>
1617
using namespace std;
@@ -19,15 +20,15 @@ Use clang-format tool to format your changes, see [CONTRIBUTING](CONTRIBUTING.md
1920
// CORRECT:
2021
#include <cassert>
2122
std::tuple<float, float> meanAndSigma(std::vector<float> const& _v);
22-
23+
```
2324
2425
## Preprocessor
2526
2627
1. File comment is always at top, and includes:
2728
- Copyright.
2829
- License.
2930
30-
2. Never use #ifdef/#define/#endif file guards. Prefer #pragma once as first line below file comment.
31+
2. Never use `#ifdef`/`#define`/`#endif` file guards. Prefer #pragma once as first line below file comment.
3132
3. Prefer static const variable to value macros.
3233
4. Prefer inline constexpr functions to function macros.
3334
@@ -82,6 +83,7 @@ Prefer exception to bool/int return type.
8283
8. Don't pass bools: prefer enumerations instead.
8384
9. Prefer enum class to straight enum.
8485
86+
```cpp
8587
// WRONG:
8688
const double d = 0;
8789
int i, j;
@@ -103,12 +105,12 @@ Prefer exception to bool/int return type.
103105
std::tuple<float, float> meanAndSigma(std::vector<float> const& _v, Accuracy _a);
104106
auto x = dynamic_cast<Derived*>(base);
105107
for (auto i = x.begin(); i != x.end(); ++i) {}
106-
108+
```
107109

108110
## Structs & classes
109111

110112
1. Structs to be used when all members public and no virtual functions.
111-
- In this case, members should be named naturally and not prefixed with 'm_'
113+
- In this case, members should be named naturally and not prefixed with `m_`
112114
2. Classes to be used in all other circumstances.
113115

114116

@@ -118,28 +120,28 @@ Prefer exception to bool/int return type.
118120
1. One member per line only.
119121
2. Private, non-static, non-const fields prefixed with m_.
120122
3. Avoid public fields, except in structs.
121-
4. Use override, final and const as much as possible.
123+
4. Use `override`, `final` and `const` as much as possible.
122124
5. No implementations with the class declaration, except:
123125
- template or force-inline method (though prefer implementation at bottom of header file).
124126
- one-line implementation (in which case include it in same line as declaration).
125-
6. For a property 'foo'
126-
- Member: m_foo;
127-
- Getter: foo(); also: for booleans, isFoo()
128-
- Setter: setFoo();
127+
6. For a property `foo`
128+
- Member: `m_foo`;
129+
- Getter: `foo()`; also: for booleans, `isFoo()`
130+
- Setter: `setFoo()`;
129131

130132

131133
## Naming
132134

133135
1. Collection conventions:
134-
- ~s means `std::vector` e.g. `using MyTypes = std::vector<MyType>`
135-
- ~Set means `std::set` e.g. `using MyTypeSet = std::set<MyType>`
136-
- ~Hash means `std::unordered_set` e.g. `using MyTypeHash = std::unordered_set<MyType>`
136+
- `...s` means `std::vector` e.g. `using MyTypes = std::vector<MyType>`
137+
- `-...Set` means `std::set` e.g. `using MyTypeSet = std::set<MyType>`
138+
- `...Hash` means `std::unordered_set` e.g. `using MyTypeHash = std::unordered_set<MyType>`
137139
2. Class conventions:
138-
- ~Face means the interface of some shared concept. (e.g. FooFace might be a pure virtual class.)
140+
- `...Face` means the interface of some shared concept. (e.g. `FooFace` might be a pure virtual class.)
139141
3. Avoid unpronounceable names:
140142
- If you need to shorten a name favour a pronouncable slice of the original to a scattered set of consonants.
141-
- e.g. Manager shortens to Man rather than Mgr.
142-
4. Avoid prefixes of initials (e.g. DON'T use IMyInterface, CMyImplementation)
143+
- e.g. `Manager` shortens to `Man` rather than `Mgr`.
144+
4. Avoid prefixes of initials (e.g. DON'T use `IMyInterface`, `CMyImplementation`)
143145
5. Find short, memorable & (at least semi-) descriptive names for commonly used classes or name-fragments.
144146
- A dictionary and thesaurus are your friends.
145147
- Spell correctly.
@@ -156,7 +158,10 @@ Prefer exception to bool/int return type.
156158
2. Generally avoid shortening a standard form that already includes all important information:
157159
- e.g. stick to `shared_ptr<X>` rather than shortening to `ptr<X>`.
158160
3. Where there are exceptions to this (due to excessive use and clear meaning), note the change prominently and use it consistently.
159-
- e.g. `using Guard = std::lock_guard<std::mutex>; ///< Guard is used throughout the codebase since it's clear in meaning and used commonly.`
161+
- e.g.
162+
```cpp
163+
using Guard = std::lock_guard<std::mutex>; ///< Guard is used throughout the codebase since it's clear in meaning and used commonly.
164+
```
160165
4. In general expressions should be roughly as important/semantically meaningful as the space they occupy.
161166

162167

0 commit comments

Comments
 (0)