Jeremias Maerki wrote:
> The following should (sorry, could) be ok:
>
>    for (int i = 0; i < 5; i++) {
>        doSomething();
>        if (amIRight()) cool();
>        doSomethingElse();
>    }

One point here:
If it's not amIRight() but

if (amIRight() || ( more stuff follows .............) cool();
doSomethingElse();

you tend to ignore the cool() stuff in favor of doSomethingElse.

I can't count the times I've seen people hunt for this kind of
bug (most when changing someone else's code, of course).

Which is why I always use:

if (foo)
  doFoo();

On the whole I think you would be served best by forbidding

if (foo) doFoo();

and allowing

if (foo)
  doFoo();
else
  doBar();

as well as

if (foo) {
  doFoo();
} 
else {
  doBar();
}

leaving this issue to personal taste.

Just my 2 cents.
--
Cappelino Informationstechnologie GmbH
Arnd Beißner

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to