From 20d4d711f8d300682d560548ec1a5501ce7b9978 Mon Sep 17 00:00:00 2001 From: max-001 Date: Wed, 6 Nov 2024 16:31:16 +0100 Subject: Added extra code-style guidelines --- contributing.md | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) (limited to 'contributing.md') 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); ``` +-
+ Follow the rule-of-five +
GoodBad
+ + ```cpp + class Foo { + public: + Foo(); + ~Foo(); + Foo(const Foo &); + Foo(Foo &&) noexcept; + Foo & operator=(const Foo &); + Foo & operator=(Foo &&) noexcept; + }; + ``` + + + ```cpp + class Foo { + public: + Foo(); + ~Foo(); + Foo(const Foo &); + }; + ``` +
+-
+ Ensure const-correctness +
GoodBad
+ + ```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; + }; + ``` + + + ```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; + }; + ``` +
+-
+ File names (.h/.cpp/.hpp) should be written using CamelCase +
GoodBad
+ + ```cpp + MyClass.h + MyClass.cpp + MyClass.hpp + ``` + + + ```cpp + my_class.h + my_class.cpp + my_class.hpp + ``` +
+-
+ Implementation is not allowed in header files, except if the method only returns a constant value +
GoodBad
+ + ```cpp + class Foo { + public: + int get_value() const { return 42; } + }; + ``` + + + ```cpp + class Foo { + public: + int calculate_value() const { + int result = 0; + // complex calculation + return result; + } + }; + ``` +
+-
+ Use angle brackets (`<>`) for including libraries and double quotes (`""`) for including local files. +
GoodBad
+ + ```cpp + #include + #include "MyClass.h" + ``` + + + ```cpp + #include "iostream" + #include + ``` +
## CMakeLists-specific -- cgit v1.2.3 From 0438e0f4d129431f7ecef7996a11b301eda882fb Mon Sep 17 00:00:00 2001 From: max-001 Date: Wed, 6 Nov 2024 16:34:09 +0100 Subject: Clarified --- contributing.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'contributing.md') diff --git a/contributing.md b/contributing.md index 91cd12b..014df51 100644 --- a/contributing.md +++ b/contributing.md @@ -479,7 +479,7 @@ that you can click on to open them. ``` -
- File names (.h/.cpp/.hpp) should be written using CamelCase + File names (.h, .cpp, .hpp) should be written using CamelCase
GoodBad
```cpp @@ -491,8 +491,8 @@ that you can click on to open them. ```cpp my_class.h - my_class.cpp - my_class.hpp + myClass.cpp + my-class.hpp ```
-
-- cgit v1.2.3 From 9e9549a8b70454610eec1b74c44eeaa78507b92c Mon Sep 17 00:00:00 2001 From: max-001 Date: Wed, 6 Nov 2024 16:39:05 +0100 Subject: Used --- contributing.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'contributing.md') diff --git a/contributing.md b/contributing.md index 014df51..8da91ee 100644 --- a/contributing.md +++ b/contributing.md @@ -49,7 +49,7 @@ that you can click on to open them. class Cars {}; ```
-- 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: @@ -479,7 +479,7 @@ that you can click on to open them. ``` -
- File names (.h, .cpp, .hpp) should be written using CamelCase + File names (.h, .cpp, .hpp) should be written using CamelCase
GoodBad
```cpp @@ -519,7 +519,7 @@ that you can click on to open them. ```
-
- Use angle brackets (`<>`) for including libraries and double quotes (`""`) for including local files. + Use angle brackets (<>) for including libraries and double quotes ("") for including local files.
GoodBad
```cpp -- cgit v1.2.3 From b7696c14052e0583519ed2315b52d39f243ff916 Mon Sep 17 00:00:00 2001 From: max-001 Date: Wed, 6 Nov 2024 16:39:54 +0100 Subject: Enter too much --- contributing.md | 1 - 1 file changed, 1 deletion(-) (limited to 'contributing.md') diff --git a/contributing.md b/contributing.md index 8da91ee..695b99b 100644 --- a/contributing.md +++ b/contributing.md @@ -54,7 +54,6 @@ that you can click on to open them. - Implementation details (if applicable) - Header files (.h) contain the following types of comments: - Usage documentation (required) - > [!NOTE] > Constructors/destructors aren't required to have a `\brief` description - Implementation details (if they affect the header) -- cgit v1.2.3 From e097ed023c3c0cf98b368f57941b16a05725f481 Mon Sep 17 00:00:00 2001 From: max-001 Date: Wed, 6 Nov 2024 16:44:34 +0100 Subject: Added hyperlink to # documentation --- contributing.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'contributing.md') diff --git a/contributing.md b/contributing.md index 695b99b..f6805ac 100644 --- a/contributing.md +++ b/contributing.md @@ -53,12 +53,9 @@ that you can click on to open them. - What is the code supposed to do (optional) - Implementation details (if applicable) - Header files (.h) contain the following types of comments: - - Usage documentation (required) + -
Usage documentation (required) > [!NOTE] > Constructors/destructors aren't required to have a `\brief` description - - Implementation details (if they affect the header) - - Design/data structure decisions (if applicable) --
Comments are placed *above* the line(s) they are explaining
GoodBad
-- cgit v1.2.3 From 7887904a68d000fa602a2eff1aabdff6a6f74a44 Mon Sep 17 00:00:00 2001 From: max-001 Date: Wed, 6 Nov 2024 16:46:01 +0100 Subject: Fix --- contributing.md | 3 +++ 1 file changed, 3 insertions(+) (limited to 'contributing.md') diff --git a/contributing.md b/contributing.md index f6805ac..ea8d724 100644 --- a/contributing.md +++ b/contributing.md @@ -56,6 +56,9 @@ that you can click on to open them. -
Usage documentation (required) > [!NOTE] > Constructors/destructors aren't required to have a `\brief` description + - Implementation details (if they affect the header) + - Design/data structure decisions (if applicable) +-
Comments are placed *above* the line(s) they are explaining
GoodBad
-- cgit v1.2.3 From 0c44c5eb59cd95990f24f11c2ac1ce1fd49537ab Mon Sep 17 00:00:00 2001 From: max-001 Date: Wed, 6 Nov 2024 16:47:39 +0100 Subject: Fix --- contributing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'contributing.md') diff --git a/contributing.md b/contributing.md index ea8d724..1e2cc87 100644 --- a/contributing.md +++ b/contributing.md @@ -53,7 +53,7 @@ that you can click on to open them. - What is the code supposed to do (optional) - Implementation details (if applicable) - Header files (.h) contain the following types of comments: - -
Usage documentation (required) + - Usage documentation (required) > [!NOTE] > Constructors/destructors aren't required to have a `\brief` description - Implementation details (if they affect the header) -- cgit v1.2.3 From b585bd7b981279b90ffd11e0feb51748b888833c Mon Sep 17 00:00:00 2001 From: max-001 Date: Wed, 6 Nov 2024 16:48:29 +0100 Subject: Fix --- contributing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'contributing.md') diff --git a/contributing.md b/contributing.md index 1e2cc87..cea6e37 100644 --- a/contributing.md +++ b/contributing.md @@ -53,7 +53,7 @@ that you can click on to open them. - What is the code supposed to do (optional) - Implementation details (if applicable) - Header files (.h) contain the following types of comments: - - Usage documentation (required) + - Usage documentation (required) > [!NOTE] > Constructors/destructors aren't required to have a `\brief` description - Implementation details (if they affect the header) -- cgit v1.2.3 From 32bc6d21987e9861d9089228388f9aab5f4f43d1 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Wed, 6 Nov 2024 18:25:10 +0100 Subject: merge #21 --- contributing.md | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) (limited to 'contributing.md') diff --git a/contributing.md b/contributing.md index cea6e37..cd1b6a6 100644 --- a/contributing.md +++ b/contributing.md @@ -49,11 +49,11 @@ that you can click on to open them. class Cars {}; ```
-- 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,7 +421,7 @@ that you can click on to open them. ```
-
- Follow the rule-of-five + Follow the rule of five
GoodBad
```cpp @@ -429,10 +429,9 @@ that you can click on to open them. public: Foo(); ~Foo(); - Foo(const Foo &); Foo(Foo &&) noexcept; - Foo & operator=(const Foo &); - Foo & operator=(Foo &&) noexcept; + Foo & operator = (const Foo &); + Foo & operator = (Foo &&) noexcept; }; ``` @@ -442,7 +441,6 @@ that you can click on to open them. public: Foo(); ~Foo(); - Foo(const Foo &); }; ```
@@ -478,7 +476,7 @@ that you can click on to open them. ```
-
- File names (.h, .cpp, .hpp) should be written using CamelCase + Files should be named after the class/struct/interface they implement
GoodBad
```cpp @@ -495,7 +493,12 @@ that you can click on to open them. ```
-
- Implementation is not allowed in header files, except if the method only returns a constant value + Implementations are not allowed in header files, except if the implementation + + - is `= default` + - is `= delete` + - is `{}` (empty) + - only returns a constant literal
GoodBad
```cpp @@ -518,18 +521,24 @@ that you can click on to open them. ```
-
- Use angle brackets (<>) for including libraries and double quotes ("") for including local files. + Use angle brackets (<>) only for including system headers and + double quotes ("") for including other engine files. + + > [!NOTE] + > Only files in the examples folder should include engine headers with angle + > brackets
GoodBad
```cpp #include - #include "MyClass.h" + + #include "facade/Sound.h" ``` ```cpp - #include "iostream" - #include + #include + #include ```
-- cgit v1.2.3