Boost logo

Boost :

From: Paul A. Bristow (pbristow_at_[hidden])
Date: 2001-07-09 13:43:39


> -----Original Message-----
> From: Douglas Gregor [mailto:gregod_at_[hidden]]
> Sent: Saturday, July 07, 2001 5:13 PM
> To: boost_at_[hidden]
> Subject: [boost] Coding guidelines: 5.1
>
I personally prefer 5.1 (Douglas Gregor/McConnell style 2
because it lines up the {} brackets.
(and from using other languages, I find this useful and comforting).

But it does waste vertical space.
However often this can be avoided by using the line for comment(s)

For example:

if (0 == i)
{ // Avoid divide by zero!
  x = 0;
} // Comment 0 == i may be helpful here if very many statements in the
block.
else
{ // i != zero so OK to divide by it.
  x /= i;
} // Can also indicate end of else section here

One practical snag is the MSVC IDE editor fights hard against doing this.

> 5.1 suggests style #2, which is the only one of the three that
> McConnell says _not_ to use, because it violates his
 "Fundamental Theorem of Formatting."

My view is that the theory is just wrong!

For me, I strongly dislike #1 and #3 regarding readability and
understandability of
code, even if the gurus seem to like it.

But there seems an irrevocably mess about layout.
Nobody is willing to change - especially me of course!

Paul

Dr Paul A Bristow, hetp Chromatography
Prizet Farmhouse
Kendal, Cumbria
LA8 8AB UK
+44 1539 561830
mailto:pbristow_at_[hidden]


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk