9.3 Curly Braces
Of the three main braces placement rules, two are acceptable, as the first of these is the best:
Place curly braces at the same column below the keyword:
if (condition)
{
...
while (condition)
{
...
}
}
The traditional Unix parentheses rule is that the first brackets are the same as the keywords, and the end brackets are the same as the keywords:
if (condition) {
...
while (condition) {
...
}
}
The non-principled problems that cause the violent controversy can be solved by means of compromise, either of which is acceptable, but for most people the first one is preferred. The reason is that psychology studies the category of learning things.
There are more reasons for liking the first. If you use a character editor that supports brace matching (for example, VI), the most important thing is to have a good style. Why? We say when you have a big program and want to know where this big program ends. You first move to the opening parenthesis, and you press the button editor to find the closing parenthesis that corresponds to it, for example:
if (verylongcondition && secondverylongcondition)
{
...
}
else if (...)
{
...
}
Moving from one program block to another requires you to match the key with the cursor and your parentheses, without looking for matching parentheses.
http://www.bkjia.com/PHPjc/532579.html www.bkjia.com true http://www.bkjia.com/PHPjc/532579.html techarticle 9.3 Braces in the three main braces placement rules, two are acceptable, as the first of the following is best: Place curly braces at the same column below the keyword: if (c ...