Place braces under and inline with keywords, like this :
Example 3-1. Braces Policy Example
if (condition) while (condition)
{ {
... ...
} }
|
- If you use an editor (such as vi) that supports brace matching, this is a much better style than the default unix style where braces aren't vertically aligned. Why? Let's say you have a large block of code and want to know where the block ends. You move to the first brace hit a key and the editor finds the matching brace.
Example 3-2. Braces Policy Justification
if (very_long_condition && second_very_long_condition)
{
...
}
else if (...)
{
...
}
|
To move from block to block you just need to use cursor down and your brace matching key. No need to move to the end of the line to match a brace then jerk back and forth.