[gnome-devel-docs] 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] programming-guidelines: long conditions are hard to read
- Date: Sat, 14 Feb 2015 18:52:09 +0000 (UTC)
commit 4181bfe6bc6cec1741b39faf7ed08a129804a80e
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 a5343d6..3ae721d 100644
--- a/programming-guidelines/C/c-coding-style.page
+++ b/programming-guidelines/C/c-coding-style.page
@@ -285,6 +285,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]