This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: coding style, continuing education


sidster wrote:
> 
> Greetings,
> 
> How about this style:

>         if
>             (
>                 [[reformatted junk elided]]
>             )


NO!  (in my most unhumble opinion).

Logical KISS rules to live by:

1.  Never, ever, more than two logical levels
2.  If you do use two, then think long and hard about having
    5-8 terms in the expression.  More than 8?
    Then consider another line of work.
3.  If only one, then, perforce, the logical expressions are
    all primitives (boolean variables or boolean expressions)
    joined by either `&&' or `||', but not both.
4.  Parenthesize everything.  *EVERY*thing.  The goal is
    absolute clarity, not typing conservation.
5.  Vertically align expressions (you did this one, good! :)
6.  If some of the expressions have side effects (set values
    in addition to testing them), then BREAK IT UP!

*sigh* ...

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]