I have seen bugs similar to the Apple link @josecgomez mentioned but more importantly the speed of understanding is just too obvious with the curly braces. There is all kinds of interesting research around code readability that I was into massively a few years ago. Now that I don’t get to code everyday, readability is REAL important to me to come up to speed quickly in a review.
#2 is also what I was taught in college (and in daycare!) and it bothers me if it is any other way… heh.
But how apropos was it that the errant code was literally:
Perform Failing-Error thru Failing-Error-Exit.
(That’s for the old crowd sitting in the Procedure Division.)
I use #2 and think #1 and #2 are acceptable due to how some other languages pre format in #1.
Everything else is blasphemy.
Kids these days…
I try not to WHILE away the hours.
Everything else just seems off.
2 for me! Its just neater.
Apparently no COBOL coders in the crowd…
And before that…
Gotta love a guy that can lean into a burn!!
To be a real (wo)man, code without the computer at all.
Ada Lovelace and Grace Hopper are still my computer idols. It’s amazing to me women don’t dominate this industry when so many milestones were done by women and IT was women’s work in the 60s. What an odd industry we are in…
I’m a staunch #2 myself.
As for Bart’s foobar, I was going to make that same comment. If I don’t include braces when there’s only one command, I always keep it on the same line. If I have an else, I will try to keep the statements lines up…
if (foo==bar) DoSomething();
Even then, half the time I’ll put the braces around this anyway. Writing the above makes me cringe a little bit anyway. I’ll usually reserve this for places where I have pretty long code, and I’m interested in seeing a larger section on my screen.
@SimsTrak you have not dealt with auto reformatting on check in then
Lots of extensions are doing a reformat on check in and returns that alignment to my original post.
I’ve not dealt with autoformatting on check in. But being a bit of a control freak, id much prefer a warning (with failure to check-in) over it “fixing” it for me.