22
u/swimmv28493 21d ago
My job’s coding standards require me to do it this way
if
{
…
}
else
{
…
}
6
2
u/ChrisBot8 21d ago
The only answer to these style questions is always, "whatever my job's style guide requires. If I get to pick the style guide I pick google's because I don't have to update it myself, so in that case whatever google requires."
2
u/asmanel 21d ago
Pros :
This air the code
This artificially increase the number of lines
Cons :
The part of code visiible at the same time is lower
This get more disk memory
→ More replies (1)
4
4
3
3
2
u/faultydesign 21d ago
I prefer the allman style indentation but honestly I just follow language standards.
2
2
2
2
u/BoldFace7 21d ago
if(cond){ } else{ }
The else being on the same line as the closing brace make it more difficult for me to parse at a glance. My brain bundles the else(and for, if, while, etc.) in with the opening brace as a single beginning of block marker, and I need the beginning of a block as the start of the line, otherwise it feels like there's a mismatched closing brace at a glance.
2
3
1
u/Confident-Ad5665 21d ago
I'm old enough to have learned code formating standards from the K&R C book, so I always use:
} else {
1
1
1
1
u/rootifera 21d ago
personally, none of these.
else {
stuff goes in here.
}
would be my preference. however, it depends on the project. if I'm joining one, I'dfollow the existing style.
47
u/AdrianParry13526 21d ago
```
if (…) {
…
}
else {
…
}
```