Indenting and brace styles


(Evan Purdy) #21

#2


(Bart Elia) #22

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.


(Heather Marie) #23

#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:


(Calvin Krusen) #24

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

    goto fail;

(Mark Wonsil) #25

Perform Failing-Error thru Failing-Error-Exit.

(That’s for the old crowd sitting in the Procedure Division.)


(Joseph Moeller) #26

I use #2 and think #1 and #2 are acceptable due to how some other languages pre format in #1.
Everything else is blasphemy.


(Randy Stulce) #27

Kids these days… :older_man:


(Charlie Smith) #28

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


(Dan) #29

#2.

Everything else just seems off.


(Jeff Gehling) #30

2 for me! Its just neater.


(Mark Wonsil) #31

Apparently no COBOL coders in the crowd… :roll_eyes:


(Chris Conn) #32

@Mark_Wonsil programming image


(Mark Wonsil) #33

And before that…

image


(Brandon Anderson) #34

Gotta love a guy that can lean into a burn!!


(Bart Elia) #35

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…


(Kevin Simon) #36

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.


(Bart Elia) #37

@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.


(Calvin Krusen) #38

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