hyperslug
September 1st, 2004, 10:48 AM
In Steve McConnell's Code Complete he discusses the pros and cons of different layout styles using braces. Here are 2 styles that are mentioned:
example 1
if ( x == 0 )
{
statement;
statement;
statement;
}
example 2
if ( x == 0 )
{
statement;
statement;
statement;
}
McConnell claims that example 2 is superior because it is a less complicated structure and it shows subordinate instructions better. You sort of have to see the pictures he draws to understand this.
The book was recently revised into a 2nd edition but most notably, his opinion on this has not changed even though VS.NET (and probably most of Microsoft) by default uses example 1.
What do all of you think about example 2? Regardless of what we all use or prefer, do you think McConnell could be right? His expertise is legendary and his research for this book is the best I've ever seen for a computer book (maybe any book).
example 1
if ( x == 0 )
{
statement;
statement;
statement;
}
example 2
if ( x == 0 )
{
statement;
statement;
statement;
}
McConnell claims that example 2 is superior because it is a less complicated structure and it shows subordinate instructions better. You sort of have to see the pictures he draws to understand this.
The book was recently revised into a 2nd edition but most notably, his opinion on this has not changed even though VS.NET (and probably most of Microsoft) by default uses example 1.
What do all of you think about example 2? Regardless of what we all use or prefer, do you think McConnell could be right? His expertise is legendary and his research for this book is the best I've ever seen for a computer book (maybe any book).