Braces – which style?

if (true)
{
    doSomething();
}
else
{
    doSomethingElse();
}

One last thing. On the C/C++ braces style. It has gotta be ‘Allman’ for me. It just looks so much more readable when there is symetry.

This entry was posted in General. Bookmark the permalink.

3 Responses to Braces – which style?

  1. I like that style to, although I prefer it without the empty lines.

  2. Dru says:

    The empty lines really aren’t there. For some reason the PRE tags are doing that.

  3. Jim says:

    IMHO, for big chunks of code:

    if ( x == y ) { DoSomething(); } else if ( x == y ) { DoSomethingElse(); } else { }

    ( 2 spaces per indent, 1 space padding )

    if ( x == y ) DoSomething(); else DoSomethingElse();

    or

    if ( x == y ) DoSomething(); else if ( x == y ) DoSomethingElse(); else if ( x == y ) DoSomethingElse(); else if ( x == y ) DoSomethingElse(); else if ( x == y ) DoSomethingElse(); else DoSomethingElse();

    Is OK, as long as there is at least one empty line above and below.

Comments are closed.