[gnome-devel-docs/wip/swilmet/various-fixes: 7/7] programming-guidelines: long conditions are hard to read
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-devel-docs/wip/swilmet/various-fixes: 7/7] programming-guidelines: long conditions are hard to read
- Date: Sat, 14 Feb 2015 12:34:32 +0000 (UTC)
commit 71ca3dff2e8b5b778212511a01e29b9ccbf0980b
Author: Sébastien Wilmet <swilmet gnome org>
Date: Fri Feb 13 17:49:21 2015 +0100
programming-guidelines: long conditions are hard to read
The introduction of the page explains that code maintainability is
important, so having a note about a programming best practice is useful
I think.
The code example was more to explain the coding style, but with the
added note, we explain that we are aware that such long conditions are
not a good example of clean code.
https://bugzilla.gnome.org/show_bug.cgi?id=744521
programming-guidelines/C/c-coding-style.page | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/programming-guidelines/C/c-coding-style.page b/programming-guidelines/C/c-coding-style.page
index 2354cf2..3b26d36 100644
--- a/programming-guidelines/C/c-coding-style.page
+++ b/programming-guidelines/C/c-coding-style.page
@@ -283,6 +283,13 @@ if (condition1 ||
{
a_single_statement ();
}</code>
+
+ <p>
+ Note that such long conditions are usually hard to understand. A
+ good practice is to set the condition to a boolean variable, with
+ a good name for that variable. Another way is to move the long
+ condition to a function.
+ </p>
</item>
<item>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]