C Programming Best Practises
But his number one rule about always using braces after if, else, switch, while, do, and for is one I don't always agree with. Why? Because too many braces can be hard to comprehend, even if formatted neatly, and I've seen applications with functions nesting 5 or 6 levels deep and being way too long. Pascal for all its sins let you nest functions and in C++, classes are better for logically grouping related variables and functions.
So do you prefer?
if (something)
dosomethingelse;
or
if (something) {
}
dosomethingelse;
- Link to C Tutorials


Well, I prefer the second way – I do really white-space style like..
void
Object::method ( const int & _size )
{
return ( _size * ( 3 – 2 ) ) ;
}
because I think it is really clear to read.. But both of the ways have some advantages and disadvantages. Probably the most difficult thing to format with second style is do-while
I prefer the first way, because,
http://lxr.linux.no/linux/Documentation/CodingStyle