This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: coding style, continuing education
- To: sidster <patrick at boxsoft dot com>, sidster <patrick at boxsoft dot com>
- Subject: Re: coding style, continuing education
- From: Bruce Korb <bkorb at cruzio dot com>
- Date: Tue, 16 Jan 2001 10:09:31 -0800
- CC: Mike Stump <mrs at windriver dot com>, gcc at gcc dot gnu dot org
- References: <200101152203.OAA29440@kankakee.wrs.com> <20010116001340.O319@3eye.boxsoft.com>
- Reply-To: bkorb at allegronetworks dot com
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* ...