aboutsummaryrefslogtreecommitdiff
path: root/contributing.md
diff options
context:
space:
mode:
authormax-001 <maxsmits21@kpnmail.nl>2024-11-06 16:31:16 +0100
committermax-001 <maxsmits21@kpnmail.nl>2024-11-06 16:31:16 +0100
commit20d4d711f8d300682d560548ec1a5501ce7b9978 (patch)
tree9685b201dfa5649c0f4fb275c7a112e4eabe10ae /contributing.md
parent4f953a35912c3d92c26bcb6c2cc77cc3ced176a3 (diff)
Added extra code-style guidelines
Diffstat (limited to 'contributing.md')
-rw-r--r--contributing.md112
1 files changed, 112 insertions, 0 deletions
diff --git a/contributing.md b/contributing.md
index 88cba32..91cd12b 100644
--- a/contributing.md
+++ b/contributing.md
@@ -421,6 +421,118 @@ that you can click on to open them.
void bar(Point p);
```
</td></tr></table></details>
+- <details><summary>
+ Follow the rule-of-five
+ </summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td>
+
+ ```cpp
+ class Foo {
+ public:
+ Foo();
+ ~Foo();
+ Foo(const Foo &);
+ Foo(Foo &&) noexcept;
+ Foo & operator=(const Foo &);
+ Foo & operator=(Foo &&) noexcept;
+ };
+ ```
+ </td><td>
+
+ ```cpp
+ class Foo {
+ public:
+ Foo();
+ ~Foo();
+ Foo(const Foo &);
+ };
+ ```
+ </td></tr></table></details>
+- <details><summary>
+ Ensure const-correctness
+ </summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td>
+
+ ```cpp
+ class Foo {
+ public:
+ int get_value() const;
+ void set_value(int new_value);
+ const std::string & get_name() const;
+ void set_name(const std::string & new_name);
+ private:
+ int value;
+ std::string name;
+ };
+ ```
+ </td><td>
+
+ ```cpp
+ class Foo {
+ public:
+ int get_value();
+ void set_value(int new_value);
+ std::string get_name();
+ void set_name(std::string new_name);
+ private:
+ int value;
+ std::string name;
+ };
+ ```
+ </td></tr></table></details>
+- <details><summary>
+ File names (.h/.cpp/.hpp) should be written using CamelCase
+ </summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td>
+
+ ```cpp
+ MyClass.h
+ MyClass.cpp
+ MyClass.hpp
+ ```
+ </td><td>
+
+ ```cpp
+ my_class.h
+ my_class.cpp
+ my_class.hpp
+ ```
+ </td></tr></table></details>
+- <details><summary>
+ Implementation is not allowed in header files, except if the method only returns a constant value
+ </summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td>
+
+ ```cpp
+ class Foo {
+ public:
+ int get_value() const { return 42; }
+ };
+ ```
+ </td><td>
+
+ ```cpp
+ class Foo {
+ public:
+ int calculate_value() const {
+ int result = 0;
+ // complex calculation
+ return result;
+ }
+ };
+ ```
+ </td></tr></table></details>
+- <details><summary>
+ Use angle brackets (`<>`) for including libraries and double quotes (`""`) for including local files.
+ </summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td>
+
+ ```cpp
+ #include <iostream>
+ #include "MyClass.h"
+ ```
+ </td><td>
+
+ ```cpp
+ #include "iostream"
+ #include <MyClass.h>
+ ```
+ </td></tr></table></details>
## CMakeLists-specific