I like the braces to line up with the statements. It helps identify the end of a group. And yes I know that all modern editors will do brace matching and what not.
I remember having exercises where we were limited to the number of lines of code we could write… curly braces were included in the line count and they forced us to use that style. Made for some interesting solutions.
BTW - I never liked that the closing brace of a C switch() statement didn’t line up …
switch(i){
case 1:
// do this
// do that
break;
case 2:
// do this for 2
// do that for 2
break;
default:
// do alternate
break;
}
When using style 7, the closing brace should be at the same indent of the line above it. And I was not going to start addinging braces to the case blocks like
May all javascript programmers who use brackets on the same line as code be strung up by their toenails
I agree Calvin, lining up braces is essential for easily being able to eyeball complex nested statements (although newer IDE’s handle this for you - Epicor not so much)
@Hogardy While i started toying with Basic, Pascal was my first real language as well. Borland Delphi
Same here, I was in the first year of High School programming class and it was Pascal, lead by some cantankerous teacher that didn’t really help us learn.
I am a fan of option 2 but wanted to note one option you did not include which I ban:
if(foo==bar)
DoSomething();
with or without spaces in front of the DoSomething I don’t care but it is too darned easy to try and add or remove logic around this and get some interesting bugs:
if(foo==bar)
DoSomething();
DoSomethingElse();
If you were clear in the initial use, you will please your future self or the axe murderer who knows your address and takes over your code in the future