aboutsummaryrefslogtreecommitdiff
path: root/contributing.md
diff options
context:
space:
mode:
authormax-001 <maxsmits21@kpnmail.nl>2024-11-07 09:54:51 +0100
committermax-001 <maxsmits21@kpnmail.nl>2024-11-07 09:54:51 +0100
commit7dfaa964a5039d7c24d16038589c77032152b9f2 (patch)
treedcb2448fa697dabcb2f248326616a16e62821125 /contributing.md
parentfd60c0280440da053948f7500657ae65b94036bf (diff)
parent3a5201961ce31d415042c6273d03e46aed7e6eb8 (diff)
Merge remote-tracking branch 'origin/master' into max/big-cleanup
Diffstat (limited to 'contributing.md')
-rw-r--r--contributing.md128
1 files changed, 124 insertions, 4 deletions
diff --git a/contributing.md b/contributing.md
index 88cba32..cd1b6a6 100644
--- a/contributing.md
+++ b/contributing.md
@@ -49,12 +49,11 @@ that you can click on to open them.
class Cars {};
```
</td></tr></table></details>
-- Source files (.cpp, .hpp) contain the following types of comments:
+- Source files (`.cpp`, `.hpp`) contain the following types of comments:
- What is the code supposed to do (optional)
- Implementation details (if applicable)
-- Header files (.h) contain the following types of comments:
- - Usage documentation (required)
-
+- Header files (`.h`) contain the following types of comments:
+ - [Usage documentation](#documentation) (required)
> [!NOTE]
> Constructors/destructors aren't required to have a `\brief` description
- Implementation details (if they affect the header)
@@ -421,6 +420,127 @@ 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(Foo &&) noexcept;
+ Foo & operator = (const Foo &);
+ Foo & operator = (Foo &&) noexcept;
+ };
+ ```
+ </td><td>
+
+ ```cpp
+ class Foo {
+ public:
+ Foo();
+ ~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>
+ Files should be named after the class/struct/interface they implement
+ </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
+ myClass.cpp
+ my-class.hpp
+ ```
+ </td></tr></table></details>
+- <details><summary>
+ Implementations are not allowed in header files, except if the implementation
+
+ - is `= default`
+ - is `= delete`
+ - is `{}` (empty)
+ - only returns a constant literal
+ </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 (<code><></code>) only for including system headers and
+ double quotes (<code>""</code>) for including other engine files.
+
+ > [!NOTE]
+ > Only files in the examples folder should include engine headers with angle
+ > brackets
+ </summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td>
+
+ ```cpp
+ #include <iostream>
+
+ #include "facade/Sound.h"
+ ```
+ </td><td>
+
+ ```cpp
+ #include <iostream>
+ #include <crepe/facade/Sound.h>
+ ```
+ </td></tr></table></details>
## CMakeLists-specific