aboutsummaryrefslogtreecommitdiff
path: root/contributing.md
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-18 15:08:31 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-18 15:08:31 +0100
commitfee42c67918a9370f7f4e074dba9a677afccf90b (patch)
treec5ed200e3c584fafc4c6bd3df48adeed3cfbd31d /contributing.md
parented1403aea4412bd479244eae8e2940190e71cd28 (diff)
parent121b64b1cb6cfead5814070c8b0185d3d7308095 (diff)
Merge remote-tracking branch 'origin/master' into niels/RenderingParticle
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 3090727..5b0c79d 100644
--- a/contributing.md
+++ b/contributing.md
@@ -678,6 +678,118 @@ that you can click on to open them.
uint64_t foo();
```
</td></tr></table></details>
+- <details><summary>
+ Utilize standard exceptions where appropriate (those found in <code>&lt;stdexcept&gt;</code>)
+ </summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td>
+
+ ```cpp
+ #include <stdexcept>
+
+ // ...
+
+ if (foo == nullptr) {
+ throw std::runtime_error("What is wrong");
+ }
+ ```
+ </td><td>
+
+ ```cpp
+ if (foo == nullptr) {
+ std::cout << "What is wrong" << std::endl;
+ exit(1);
+ }
+ ```
+ </td></tr></table></details>
+- <details><summary>
+ Mention the name of the class when throwing an exception
+ </summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td>
+
+ ```cpp
+ Foo::bar() {
+ if (...)
+ throw std::runtime_error("Foo: big error!");
+ }
+ ```
+ </td><td>
+
+ ```cpp
+ Foo::bar() {
+ if (...)
+ throw std::runtime_error("big error!");
+ }
+ ```
+ </td></tr></table></details>
+- <details><summary>
+ Constructors of classes derived from <code>Component</code> should be
+ protected and <code>ComponentManager</code> should be declared as a friend
+ class.
+ </summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td>
+
+ ```cpp
+ class MyComponent : public Component {
+ protected:
+ MyComponent(...);
+ //! Only ComponentManager is allowed to create components
+ friend class ComponentManager;
+ };
+ ```
+ </td><td>
+
+ ```cpp
+ class MyComponent : public Component {
+ public:
+ MyComponent(...);
+ };
+ ```
+ </td></tr></table></details>
+- <details><summary>
+ C++ <code>std::format</code> should be used instead of C-style format specifiers
+ </summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td>
+
+ ```cpp
+ std::string message = std::format("Hello, {}", name);
+
+ dbg_logf("Here too: {}", 3);
+
+ throw std::runtime_error(std::format("Or here: {}", 5));
+ ```
+ </td><td>
+
+ ```cpp
+ char message[50];
+ sprintf(message, "Hello, %s", name);
+ ```
+ </td></tr></table></details>
+- <details><summary>
+ Argument names should be added in <code>.h</code> files (not only in
+ <code>.cpp</code> and <code>.hpp</code> files)
+ </summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td>
+
+ Foo.h:
+ ```cpp
+ void foo(int bar);
+ ```
+
+ Foo.cpp:
+ ```cpp
+ void foo(int bar) {
+ // ...
+ }
+ ```
+ </td><td>
+
+ Foo.h:
+ ```cpp
+ void foo(int);
+ ```
+
+ Foo.cpp:
+ ```cpp
+ void foo(int bar) {
+ // ...
+ }
+ ```
+ </td></tr></table></details>
## CMakeLists-specific