diff --git a/C%2FC%2B%2B-Coding-Conventions.md b/C%2FC%2B%2B-Coding-Conventions.md new file mode 100644 index 0000000..ae9cd08 --- /dev/null +++ b/C%2FC%2B%2B-Coding-Conventions.md @@ -0,0 +1,41 @@ +### Вот некоторые соглашения которые сейчас используются и должны использоваться дальше в нашем коде: +**1. We use include guards instead of #pragma once** +**2. 3rd-party headers must be included using <>, and our files - using ""** +**3. Author information, like "Created by John Doe on xx.xx.xxxx", which is inserted automatically by many IDEs when creating a new file, is not allowed and must be removed** + +**4. General naming conventions examples:** + + +| Entity | Example | +| -------- | -------- | +| Function | doSomething | +| Local variable | my_variable | +| Public data member | my_member | +| Class | MyClass | +| Template parameter | Type,T,C,T1,T2,... | +| Constant (including static const members of a class) | MyConstant | +| Member of enum | MyEnumMember | +| Namespace | MyNamespace | + +| Property accessors | example | +| -------- | -------- | +| Setter | setFoo | +| Getter | foo | +| Boolean getters | canFoo, hasFoo, isFoo, ... | + +**5. For asynchronous functions use suffix "Async"**, e.g: `void loadAsync()` +**6. Avoid using `[&]` or `[=]` as lambda captions. It often causes problems with dangling references.** +**7. Put bodies of selection and iteration statements into compound blocks, even if the body is a one-liner** E.g.: +``` + // Bad + if (x) + doSomething(); + + // Good + if (x) + { + doSomething(); + } +``` + +