Let's start with braces. Deciding how to align braces can be the single most controversial topic between programmers. Since the choice of brace style is arbitrary and unimportant, most of us are quite ferocious and unyielding in our prejudices about it.
You have three choices. Choice one is often called K&R, after. Brian Kernighan and Dennis Ritchie, whose seminal book The C Programming Language taught so many of us how to program. The classic K&R style is this:
if ( condition == true ){
a += b;
SomeFunction();
if ( c == d ){
SomeOtherFunction();
}
}
An alternative is to indent the braces:
if ( condition == true )
{
a += b;
SomeFunction();
if ( c == d )
{
SomeOtherFunction();
}
}
I honestly don't know anyone who likes this style, but you do see it used now and again.
The third variant aligns the braces with the conditional, and there is no code on the same line as the brace:
if ( condition == true )
{
a += b;
SomeFunction();
if ( c == d )
{
SomeOtherFunction();
}
}
I used to use K&R and believed it was the only right solution. About five years ago I switched over to the third option, and now I know that this one, of course, is the only true way to write code. The important thing to remember is that whatever style you adopt, you should use it consistently.