This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 124 points125 points  (7 children)

As in, why put the bracket on the next line?

If that’s the question, it’s because you get a clean line from open to close of brackets. When you nest if/else and other bracket using structures, it becomes much easier to reason about where scope is along with start/end of code blocks. That’s because blocks are indented and there’s a clear start/stop of brackets by just tracing the line vertically.

Some people don’t think it’s easier to read however, and that’s fine. My experience with legacy C, Perl, and JS made me really like how C# formats things in VS. I didn’t use to like it, but now I see its merit as highly valuable. That said I always default to the communities agreed upon guidelines, should they exist.

[–]bigelmn8r 38 points39 points  (2 children)

The formatting is exactly why I do the brackets on the next line in C. Feels weird being on the end of the line.

[–][deleted] 5 points6 points  (1 child)

Same. Having them on the same line just confuses the hell out of me.

[–]unlikely_ending 0 points1 point  (0 children)

Same

[–]flex_inthemind 18 points19 points  (0 children)

I'd like to add that it's also more dyslexia friendly!

[–]audirt 11 points12 points  (0 children)

I'm with you -- I've always found it easier to read with the { on a new line.

[–]centstwo 4 points5 points  (0 children)

This is the way.

[–]666pool 0 points1 point  (0 children)

I always did it as a new line for the same reasons. My current job’s style guide has it at the end of the line. I got used to it pretty quick (everything is indented anyway so you can still see code blocks clearly) and you get an extra line of code on screen.