Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
CharByte71310yI do the second when I'm making the function, when I'm happy with it and it's working I change it to the first. -
Gauthier184710y@LucaScorpion Both are standards in C and C++. You do what's already in the code base. -
Gauthier184710yIncidentally, third type like the GNU people:
if (condition)
{
function(blah);
}
Indent 2 for curlies, 4 for body. -
Queenbiscuit7710yUsed to do the second one but after working on way too much Java is think I'm now the first -
beverest3410ydid the second, now I do the first. for some reason when I switched I felt like a wizard. -
StanTheMan130810yI use the first one... I just hate using a whole line for a single curly bracket. No need. Also it looks more clean, optimized and sensible. -
Wabby103110yFormer.
However, for the sanity of my staff, I have recently started training myself to do the latter.
All this conforming to standards and best practices bullshit. -
johnc4567010yLatter.
I find it makes matching up the braces easier if I'm looking for them at the same indentation. -
-bgm-31510yVisual Studio refactors to the latter one automatically when coding in C#/.NET mvc.
But when I'm not coding for work I'm the former. -
JavaRules157710y@Wabby How does this apply to best practices? It has absolutely no impact. It's a first world programmer bugbear. -
Bikonja236310yDepends on which language I'm using, but if given he choice - latter because it's easier to see whether the if has a block in curly braces or just a one liner.
Imagine:
if (expression)
statement1;
statement2;
}
statement3;
in some bigger chunk of code (with the opening curly)... The indentation can easily fool you into thinking both 1 and 2 are gonna execute only if the expression is true... So I think the one line for the opening brace is worth it, otherwise I'd say go for:
if (expression) {
statement1; }
statement2;
to save the extra line for the closing curly, too.
Related Rants

most evil thing to do...
If you do this..
I'm the former...
undefined
two types of people
syntax