I always write my conditionals the same:
if (number == 1)
{
name = "a";
}
else if (number == 2)
{
name = "b";
}
It's easy to read and consistent. Consistent with if statements that have more than one statement, etc...
Edit
To expand on this, I try to follow this rule:
Each line does one thing.
That is, each line should execute one statement (and scope should be easily visible). So I do not prefer:
if (number==1) name ="a";
Because two things are happening on one line, which makes reading and debugging more difficult than it should be. So I would move to:
if (number==1)
name ="a";
But this has the problem that it's inconsistent with a multi-statement if. That's why (as other have stated) it's good to place brackets around things:
if (number==1)
{
name ="a";
}
The reason I prefer the '{' on it's own line is that when I scan the code, I can quickly identify where a scope begins and ends. It also follows the one statement rule, since having 'if' and '{' does an if statement and starts a new scope.
I do not think that, "it saves vertical whitespace" is a good enough reason to skip readability and good formatting (both {}'s on the same column == sexy). This is because considering the resolution of today's monitors, you don't need to struggle to view code.