Difference between revisions of "Talk:New code guidelines"
m |
|||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | <Kissaki> | + | <Kissaki> I would add {} to if() return; as well<br> |
+ | removes a special <br> | ||
+ | and something may be added even to a return block | ||
− | <Kissaki> I would | + | <Kissaki> The constructor example code specifically shows why I would prefer opening braces in a new line. You can't easily distinguish where the head ends and the body block begins. |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | Foo::Foo(int a, QObject *parent) | |
+ | : QObject(parent) | ||
+ | , m_a(a) { | ||
+ | doStuff(); | ||
+ | }; | ||
− | + | Also, the if block: | |
− | + | if (a > b | |
− | + | || b > c | |
+ | || c > d) { | ||
+ | doSomething(); | ||
+ | } else { | ||
+ | doSomethingElse(); | ||
+ | } |
Latest revision as of 17:29, 18 September 2013
<Kissaki> I would add {} to if() return; as well
removes a special
and something may be added even to a return block
<Kissaki> The constructor example code specifically shows why I would prefer opening braces in a new line. You can't easily distinguish where the head ends and the body block begins.
Foo::Foo(int a, QObject *parent) : QObject(parent) , m_a(a) { doStuff(); };
Also, the if block:
if (a > b || b > c || c > d) { doSomething(); } else { doSomethingElse(); }