mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
Documentation: Swap 'Right' and 'Wrong' code practice
This commit is contained in:
parent
6e00dd64a1
commit
ed271aa7c5
Notes:
sideshowbarker
2024-07-17 20:43:53 +09:00
Author: https://github.com/flyingwombat921 🔰 Commit: https://github.com/SerenityOS/serenity/commit/ed271aa7c5e Pull-request: https://github.com/SerenityOS/serenity/pull/11955
1 changed files with 16 additions and 16 deletions
|
@ -514,22 +514,6 @@ 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:
|
||||
|
||||
```cpp
|
||||
i++; // Increment i.
|
||||
```
|
||||
|
||||
```cpp
|
||||
// If the user clicks, toggle the timer state.
|
||||
catdog_widget.on_click = [&] {
|
||||
if (advice_timer->is_active())
|
||||
advice_timer->stop();
|
||||
else
|
||||
advice_timer->start();
|
||||
};
|
||||
```
|
||||
|
||||
###### Right:
|
||||
|
||||
```cpp
|
||||
|
@ -552,6 +536,22 @@ catdog_widget.on_click = [&] {
|
|||
page_index++;
|
||||
```
|
||||
|
||||
###### Wrong:
|
||||
|
||||
```cpp
|
||||
i++; // Increment i.
|
||||
```
|
||||
|
||||
```cpp
|
||||
// If the user clicks, toggle the timer state.
|
||||
catdog_widget.on_click = [&] {
|
||||
if (advice_timer->is_active())
|
||||
advice_timer->stop();
|
||||
else
|
||||
advice_timer->start();
|
||||
};
|
||||
```
|
||||
|
||||
### 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.
|
||||
|
|
Loading…
Reference in a new issue