Indenting and brace styles

#2

1 Like

Exactly!
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.

1 Like

#2 is also what I was taught in college (and in daycare!:baby:) and it bothers me if it is any other way… heh. :crazy_face:

1 Like

But how apropos was it that the errant code was literally:

    goto fail;
2 Likes

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.

2 Likes

Kids these days… :older_man:

1 Like

I try not to WHILE away the hours.
:blush:

1 Like

#2.

Everything else just seems off.

1 Like

2 for me! Its just neater.

1 Like

Apparently no COBOL coders in the crowd… :roll_eyes:

@Mark_Wonsil programming image

4 Likes

And before that…

image

3 Likes

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…

3 Likes

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();
else DoSomethingElse();

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.

2 Likes

@SimsTrak you have not dealt with auto reformatting on check in then :wink:

Lots of extensions are doing a reformat on check in and returns that alignment to my original post.

2 Likes

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.

As a side note, has anyone used a code minimzer? Not an optimizer, but one that reduces the source code by renaming variables to shorter ones, and removing whitespaces(including CRs and LFs). Obviously only useful for “interpreted languages”. A lot of JavaScript has this done. jQuery-min.js is the minimized version of jQuery.js