What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 134 Stack Exchange communities.

Some people like to put the open { bracket on a separated line, e.g:

if(...)
{
    //...
}

Is editing this code by merging the first two lines into single one rude?

share|improve this question
    
I hope this is not a dup, I failed to find any with this query –  ajax333221 May 21 '12 at 22:34
    
Did you have a specific edit in mind? –  Flexo May 21 '12 at 22:38
7  
This falls into the category of "trivial edits" because you're not substantively improving the post. I don't think it's "rude", but it's certainly to be discouraged. –  Cody Gray May 21 '12 at 22:39
6  
it will be funny if someone did that with this example n_n –  ajax333221 May 21 '12 at 22:40
1  
It was funny. Now it's even funnier! –  Shogging through the snow May 22 '12 at 4:16
1  
@Shog9 It was not as funny as I thought... But after all, he answered my question without even submitting an answer. Well played Jacques Cousteau, well played... –  ajax333221 May 22 '12 at 4:18
    
I'm fine with the brackets but if(...) really is an eyesore –  prusswan Sep 7 '12 at 21:46
    
Someone just did that and I reverted their change –  CashCow Sep 16 at 17:10

5 Answers 5

up vote 22 down vote accepted

Is it rude? Yes. Mostly because that brace style is ugly as sin, but also because you're imposing your personal preferences on someone else's writing without good cause.

But yeah, mostly because that brace positioning style sucks.

That said, if doing so helps you trim down a code block so that it can be read without scrolling... AND you're making other substantial improvements at the same time (indentation, formatting, grammar, tags, etc.)... Then go ahead.

Related: Etiquette on editing source code formatting for style preferences

share|improve this answer
10  
I agree that it's rude, but I don't agree with (most of) your reasoning. I have a strong personal opinion about which brace style is best. I consider changing posted code from the Bad Brace Style to the Good Brace Style to be exactly as rude as changing code from the Good Brace Style to the Bad Brace Style. (I refuse to identify which is which; everyone reading this comment may assume I agree with them.) –  Keith Thompson May 22 '12 at 1:57
4  
Of course, lots of us do @Keith. So as soon as you change it, you're guaranteed to be making it more unpleasant for someone to read. And in ajax's case, that someone will always include me ;-) But yeah - when you're reformatting the code from "I wrote this in Notepad with a broken spacebar", you can pretty much pick whatever style you want and it'll be an improvement; otherwise, first do no harm. –  Shogging through the snow May 22 '12 at 2:02
    
"The author of this FAQ sees no clear advantage to adopting this approach and believes that said developers also put their curly braces on the wrong line."—JUnit FAQ –  trashgod May 22 '12 at 3:10

Rude or not it is an invitation to start a holy war.

We go to great lengths to keep brace style wars off the site. Please don't invite them on.


OTBS Rules!

share|improve this answer
    
What is OTBS please? –  James Webster Sep 18 '13 at 13:39
2  
"One True Brace Style". Roughly the system used in K&R and my personal favorite. You'll find that many otherwise sensible and quite skilled programmers don't like it much. –  dmckee Sep 18 '13 at 14:25
    
I am one of those "otherwise sensible and quite skilled programmers [who doesn't] like it much" =P –  James Webster Sep 18 '13 at 14:27

Generally, you'll want to leave the OP's coding style alone. Unless it makes the code overbearingly hard to read or excessively long (they do that for every single function of a rather long block of code), there's really no need to change it. The only thing you need to focus on is making sure that their indentation is correct. That extra line for the opening bracket isn't going to bother an experienced programmer who has seen it both ways many, many times.

share|improve this answer
    
That extra line is going to please an experienced programmer who has put it there many, many times. –  Bo Persson May 22 '12 at 16:00

Don't edit just to fiddle with the braces.

However, if in the course of trying to repair severely horrible code formatting, you run the code through Lindent or your own favorite set of indent(1) arguments, and the braces happen to change, don't go to significant effort to put them back, either.

share|improve this answer

It's generally accepted that you shouldn't do any more than

  • formatting into a markdown code block

  • if you're feeling generous, removing cruft like rogue tabs and making sure the code all lines up nicely (whilst honouring the OP's brace style)

  • where the language allows statements over multiple lines, adding a carriage return (and where required a line continuation character) here and there to reduce horizontal scroll.

  • removing excessive carriage returns between lines of code

Changing code style would be off-limits, as would doing things like turning (using C# as an example):

List<Thing> things = repo.GetThings()

into

var things = repo.GetThings()

Because now you're no longer working with the same code the OP is trying to debug.

See also:

When is it appropriate to edit someone else's code?

How far can I refactor the code in someone else's question? -

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .