[gnome-devel-docs/wip/swilmet/various-fixes] programming-guidelines: long conditions are hard to read



commit d26b78e2a9a055309915ee4d515673b1b6034c3f
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.

 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]