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.

I have noticed a significant number of suggested edits that attempt to fix code, or change the original meaning of someone else's post.

Is this really a good idea?

I've been on StackOverflow awhile, and among the editors who have sufficient reputation to edit without approval, I've never seen anyone modify the technical content or meaning of someone else's post.

I would consider obvious syntax and spelling errors OK to change, but I have seen many suggested edits that change the meaning of the code that was posted, or add things to the code that have nothing to do with the original question. A good example of this would be adding parameters to a SQL command, when the question was not asking about SQL injection.

share|improve this question
4  
I agree, I've seen the same thing and this is a concerning trend. –  Pëkka Feb 10 '11 at 17:14
2  
Is there a reason you're asking this about suggested edits, instead of generalizing it to all edits? –  Pops Feb 10 '11 at 17:15
2  
FWIW, I have made technical modifications to answers where doing so corrects or enhances what already existed without fundamentally changing the answer. That said, some of the edits I've seen suggested fail to provide either significant improvements or even explain their rationale for changing things. No harm in rejecting... –  Shogging through the snow Feb 10 '11 at 17:17
1  
@Pop the suggested edit queue is really full of such edits, while I have never seen this being done on a large scale before through the normal edit function –  Pëkka Feb 10 '11 at 17:20
    
@Pekka, I get that, but since this is a theoretical question about policy/best practices, I think it'd be better to just include everything. Certainly wouldn't hurt. –  Pops Feb 10 '11 at 17:25
1  
    
FYI - vaguely related: meta.stackexchange.com/questions/75250 –  The Anti-Santa Feb 10 '11 at 23:43
    
Related : meta.stackexchange.com/questions/75973/… –  Benjol Feb 15 '11 at 11:00
    
@Popular: It was never a problem when people had to earn their editing privileges with rep. –  Robert Harvey Aug 31 '11 at 4:08
    
In this case, what actually happens seems irrelevant to me. Focusing on suggested edits can make it appear as though it is okay for non-suggested edits to change the technical content of a post. I know, you never say that, but that's kind of how people talk (in my experience, at least). –  Pops Aug 31 '11 at 14:31

6 Answers 6

No.

Any change that affects the code posted in a question should be rejected.

If the edit changes the meaning of the post it should also be rejected.

For my own part I think that the only time changes to code are acceptable if it's in the answer and the answer is old (for some definition of "old"). For new answers I usually post a comment.

For more general advice see @waffles' answer to this question

share|improve this answer
1  
My practice on answers is to post a comment on the answer explaining the inaccuracy in their code. –  Robert Harvey Feb 10 '11 at 17:04
    
@Robert - that's what I usually do too, but for old answers it might be OK. I'll qualify the statement. –  ChrisF Feb 10 '11 at 17:06
1  
@Robert: Same here. Unless I've run the code myself and fixed a really obvious bug like a missing semicolon, I'd rather not take a chance on messing up someone else's answer. –  Bill the Lizard Feb 10 '11 at 17:06
    
@waffles seems to disagree: meta.stackexchange.com/questions/78438/… –  SLaks Feb 10 '11 at 19:24
    
@SLaks - I was specifically answering about edits to code in questions. I rushed my the part about edits to code in answers. @waffles' points are correct for anything you see wrong in any answer. –  ChrisF Feb 10 '11 at 19:28

Positively not. The intent of the original poster should be preserved. Any edit should serve to make that intent clearer.

Additionally, editing 'bugs' in posted code might just obfuscate the actual problem. I've seen so many "Can you post code that actually compiles??" comments, I guess it's only natural that some of them now try to 'fix' the root of the question. If the code actually compiled, there probably wouldn't be a question :)

share|improve this answer
    
+1 because of your second paragraph, but your first paragraph worries me. Some well-meaning editor could be trying to clarify intent by fixing the syntax error that was causing the OP's problem in the first place. –  Pops Feb 10 '11 at 17:19
    
@Popular Demand - That's why I addressed each scenario. The first paragraph was speaking generally, the second explicitly talking about editing code samples. –  Tim Post Feb 10 '11 at 18:32
2  
+1 There's some russian bloke going around fixing people's code samples in .NET questions just now. I think it's a bad idea. Especially his habit of changing from explicit types to implicit types without there being any evidence that the OP is using C#3 or later. There was one question I came across a while back where he had almost fixed the problem the OP was having (wish I'd bookmarked it) which is kinda missing the point. –  The Anti-Santa Feb 10 '11 at 23:48

I've refused a few suggested edits that have attempted to change the meaning of an answer. My rule of thumb is that if I wouldn't be comfortable making an edit myself, then I won't approve it for someone else.

share|improve this answer

My rule of thumb: never try to "fix" someone else's code. That little "typo" may just as well be a whole different class that you didn't know existed. I only fix code formatting not the code itself.

share|improve this answer

I'm surprised by the dominant response here, which goes against what the Stack Exchange guides advise and what seems to be widely practiced by editors. From the FAQ:

Like Wikipedia, this site is collaboratively edited, and all edits are tracked. If you are not comfortable with the idea of your questions and answers being edited by other trusted users, this may not be the site for you.

From the edit privilege guide:

Any time you feel you can make the post better, and are inclined to do so. Editing is encouraged!

Some common reasons to edit are:

  • to fix grammatical or spelling mistakes
  • to clarify the meaning of a post without changing it
  • correct minor mistakes or add addendums / updates as the post ages
  • add related resources or hyperlinks

From Jeff's blog post:

I’m proud to announce that we allow anonymous and new users to edit content in our system! The surface area of this change is huge — it means the millions of drive-by anonymous users that visit our sites every day can submit an improvement or correction.

So yes, if a post can be made better with an edit that changes its technical content from being broken to being correct, go ahead and make or suggest that edit!

In questions, this rarely arises if ever. But in answers, if the overall solution is good but there's a localized mistake somewhere, do fix it. A typical example is code that was typed directly in the browser, and doesn't compile: please do fix it into working code if you can. Another example is an answer that contains a major security problem, like an SQL injection: if correcting that is just a matter of adding proper escaping, please fix it.

To clarify the SQL injection example: I hold suggested edits to the same standards as normal edits. If the security of constructed SQL queries is the topic of the question and the answer contains vulnerable code, it's a wrong answer that should be downvoted, with a comment explaining the mistake (if the code is wrong, the accompanying explanation is presumably wrong too anyway — unless the error in the code is an obvious typo, in which case it should be fixed). If security was not a primary concern of the question, then the code should be fixed. We don't want examples of bad code to be left around unchecked.

share|improve this answer
3  
No one ever edited anybody else's code until suggested edits came along. It was generally understood that this was bad etiquette. The convention was to leave a comment explaining why the code was incorrect, and let the author fix his own code. –  Robert Harvey Jun 26 '11 at 1:23
1  
@RobertHarvey I certainly did edit other people's code before that. I aggressively edit misquoted shell code (and leave a comment explaining basic quoting rules). (That's the shell equivalent of escaping SQL queries you're constructing; generally it's a matter of adding a few " characters in choice places.) From day 1 at Stack Overflow, having read the FAQ and the edit privilege guide of the time, I understood it to be desired behavior. If it isn't, you have a lot of FAQ and guide rewriting to do. –  Gilles Jun 26 '11 at 10:43
2  
@robert that's a bizarre interpretation that I don't share -- I mean, if you're adding a missing semicolon, that's forbidden? –  Jeff Atwood Aug 31 '11 at 3:42
    
@Jeff: Adding a missing semicolon is probably OK, as long as it won't change the intended meaning of the code. As with all "rules", there are edge cases. Obvious misspellings and trivial errors I would consider OK to change, but I have seen many suggested edits that change the meaning of the code that was posted, or add things to the code that have nothing to do with the original question. A good example of this would be adding parameters to a SQL command, when the question was not asking about SQL injection. I generally reject such edits. –  Robert Harvey Aug 31 '11 at 3:53
    
@robert I see; it might be good to edit your answer to make that more clear (copy paste of above would be sufficient). –  Jeff Atwood Aug 31 '11 at 4:01
2  
@RobertHarvey I will continue to accept such edits until the policy is changed. And if the policy is changed, I will be a lot less positive when recommending Stack Overflow, where it's encouraged to leave broken code lying around. –  Gilles Aug 31 '11 at 7:16
1  
It depends on how you define 'broken', doesn't it? It may violate what you consider a good programming practice, but that doesn't necessarily mean the code is broken. –  Robert Harvey Aug 31 '11 at 14:42

Actually there are two parts to your questions:

I have noticed a significant number of suggested edits that attempt to fix code,

Fix code is fairly broad. For example, this edit is fine:

acepts=2; accepts += 1    =>    accepts=2; accepts += 1

I would accept simple code fixes which were clearly a trivial mistake by the author.

There is another edge case where the edit is "probably" good but really the owner needs to decide, in those cases I include a permalink to the edit on the post as a comment on the post and reject it.

or change the original meaning of someone else's post.

Changing meaning is a huge no-no that should totally be rejected.

share|improve this answer

You must log in to answer this question.

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