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.

Sometimes I see code like this on Stackoverflow:

int main()
{
if(true){
return 0;
}
else{
return 1;
}
while(true){return -1;}
}

I will usually suggest this edit:

int main()
{
    if(true){
        return 0;
    }
    else{
        return 1;
    }
    while(true){return -1;}
}

I feel like not using spaces before and after brackets is OP's style, and should be respected. Indention however should be mandatory.

My edit was followed by another edit from a user:

int main()
{
    if(true)
    {
        return 0;
    }
    else {
        return 1;
    }
    while(true) { return -1; }
}

Should I've done this in the first place? I find it more readable the latter way, but OP may not be happy about it.

Of course it is nitpicking what I do now, but what about if the post is edited again in this way:

int main( ) {
    if( true ) {
        return 0;
    } else {
        return 1;
    }
    while( true ) { 
        return -1;
    }
}

Is this tolerable? My question is: should the formatting style be mimicked when editing posts? If so, what parts should be mimicked?

share|improve this question

marked as duplicate by Cody Gray, Tobias Kienzler, hims056, gnat, Doorknob 冰 Aug 21 '13 at 12:53

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

3  
Dont overthink this. Use one consistent style, and if it turns out readable, great. If not, make changes again. The second edit should ideally not have been done, as it is trivial. –  AsheeshR Aug 20 '13 at 14:28
1  
Personally, I never change from K&R style to C# style (etc.) or vice versa. I'm also glad Markdown doesn't make a distinction between spaces and tabs. –  mmyers Aug 20 '13 at 15:44
2  
Whichever style you use, your likely to annoy someone. Just adding the indentation is the least bad option. –  parkydr Aug 20 '13 at 16:31
    
Indentation it is, I won't change the style. (no-one should) –  FalconC Aug 20 '13 at 17:15

1 Answer 1

up vote 1 down vote accepted

I dislike the original style. The only people that use this style are newcomers to C family of languages programming, and it's difficult for the veterans to read.

I'm not particular about which style is chosen to replace it, although there are accepted conventions that can be used. If you're programming in Javascript, it almost certainly should be style 2, because that's pretty much what everyone uses. If you're programming in C#, it should be style 3.

But once reformatting occurs, changing it again is going to produce diminishing returns, and the one thing you don't want to do is get into an edit war over brace style.

Note that users with editing privileges get a little more leeway than those making suggested edits, because suggested editors are asking for time from the community to review their edits, so their edits are required to be more substantial than just changing the brace style from K&R to Allman.

share|improve this answer
    
From now I'll edit the code like in codeblock 3. Readable for everyone and respecting OP's brace style. –  FalconC Aug 20 '13 at 17:18

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