summaryrefslogtreecommitdiff
path: root/Documentation
diff options
context:
space:
mode:
authorflyingwombat921 <xmilorz@gmail.com>2022-01-16 22:52:43 +0100
committerBrian Gianforcaro <b.gianfo@gmail.com>2022-01-16 15:16:44 -0800
commited271aa7c5e048bea215decc4c39a3063776dd75 (patch)
treece50f993b7e23ed3d49544ff2e805c2901597e0e /Documentation
parent6e00dd64a1a8e37c8389759141b7d0226fe597c8 (diff)
downloadserenity-ed271aa7c5e048bea215decc4c39a3063776dd75.zip
Documentation: Swap 'Right' and 'Wrong' code practice
Diffstat (limited to 'Documentation')
-rw-r--r--Documentation/CodingStyle.md24
1 files changed, 12 insertions, 12 deletions
diff --git a/Documentation/CodingStyle.md b/Documentation/CodingStyle.md
index 2cd7aa1b94..385867c20e 100644
--- a/Documentation/CodingStyle.md
+++ b/Documentation/CodingStyle.md
@@ -514,14 +514,14 @@ draw_jpg(); // TODO: Make this code handle jpg in addition to the png support.
Explain *why* the code does something. The code itself should already say what is happening.
-###### Wrong:
+###### Right:
```cpp
-i++; // Increment i.
+i++; // Go to the next page.
```
```cpp
-// If the user clicks, toggle the timer state.
+// Let users toggle the advice functionality by clicking on catdog.
catdog_widget.on_click = [&] {
if (advice_timer->is_active())
advice_timer->stop();
@@ -530,14 +530,20 @@ catdog_widget.on_click = [&] {
};
```
-###### Right:
+###### Even better:
```cpp
-i++; // Go to the next page.
+page_index++;
+```
+
+###### Wrong:
+
+```cpp
+i++; // Increment i.
```
```cpp
-// Let users toggle the advice functionality by clicking on catdog.
+// If the user clicks, toggle the timer state.
catdog_widget.on_click = [&] {
if (advice_timer->is_active())
advice_timer->stop();
@@ -546,12 +552,6 @@ catdog_widget.on_click = [&] {
};
```
-###### Even better:
-
-```cpp
-page_index++;
-```
-
### Overriding Virtual Methods
The declaration of a virtual method inside a class must be declared with the `virtual` keyword. All subclasses of that class must either specify the `override` keyword when overriding the virtual method or the `final` keyword when overriding the virtual method and requiring that no further subclasses can override it.