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.

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

Intuitively I would think the following guidelines would be appropriate:

Minor or subtle bugs: Edit the code to fix the bug, retaining the original author's intent.

Major bugs or fundamental flaws: Provide your own answer without those bugs or flaws, or comment on the answer.

However, an edit I suggested to a very old, slightly wrong answer was rejected by two users. So, I gather my intuitions don't match SO users' conventions (or possibly, there's something wrong with my suggestion that is not adequately described by their reasons for rejection).

What factors determine whether it is appropriate to edit somebody else's code to fix a bug?

share|improve this question

marked as duplicate by Michael Mrozek, Pops, Adam Davis, Cody Gray, Lightness Races in Orbit Mar 1 '12 at 19:03

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.

    
@Michael Mrozek: Indeed, that answers my question. Thank you. –  Jason Burbage Mar 1 '12 at 18:26
    
Guidelines: Don't edit code in questions, no matter what. Post a comment or an answer, instead. Feel free to edit what appear to be minor mistakes in code appearing in answers. Don't make edits that change the logic or make other significant modifications to code in answers, leave a comment instead or post an alternative answer of your own (justifying why you think it's a superior approach). –  Cody Gray Mar 1 '12 at 18:42

2 Answers 2

up vote 6 down vote accepted

Generally, I don't edit other people's posts to fix bugs. Instead, I leave a comment to the poster explaining that the code has an error and how to fix it, or I post my own answer if their answer requires significant changes to fix.

In other words, I don't edit a post if it will change its meaning, whether it's code or someone just trying to explain a point.

The only time I will edit code is to fix a syntactical error (clearly misspelled identifier, missing semicolon, etc), in the same manner I would fix a spelling error or missing punctuation in a paragraph.

share|improve this answer

As you are changing the called function, you are altering the question in a significant way.

The guidelines for editing a questions are the following ones:

  • fix grammatical or spelling errors
  • clarify meaning without changing it
  • correct minor mistakes
  • add related resources or links
  • always respect the original author

As you are not correcting a minor mistake (that would be writing code that calls explde(), when it's clear the function the user meant is explode()), and the answer is an old one, there is no reason for editing it to replace the split() call with the explode() call.

If you have reason to believe that explode() should be instead used, you can add your answer explaining that, or simply comment the answer given from that user.

share|improve this answer
    
I think you got it backwards; his edit suggests replacing split() with explode(). –  Robert Harvey Mar 1 '12 at 18:21
    
Using explode is not a mistake. Using split is a mistake. Try the code; it doesn't work. –  Jason Burbage Mar 1 '12 at 18:23
1  
@Jason: It doesn't matter whether the code works or not. –  Robert Harvey Mar 1 '12 at 18:26
    
To clarify, I was only responding to the statement "you are not correcting a minor mistake" and not defending my edit. –  Jason Burbage Mar 1 '12 at 18:27
    
@RobertHarvey Whoops… You are right; I got confused when writing the answer. –  kiamlaluno Mar 1 '12 at 18:28
1  
The question is not about questions, but answers. Imho, this is an important distinction. –  user unknown Mar 1 '12 at 18:31
    
@JasonBurbage If the code doesn't work, then what corrected is not a minor mistake. If the code doesn't work, then the answer is possibly wrong. –  kiamlaluno Mar 1 '12 at 18:31
    
@kiamlaluno Hm. Well maybe we disagree about what is "minor". The code as written never produces correct output, but it is very easy to understand and fix. Regardless, it sounds as if users agree that the code's behavior should not be changed in any case. –  Jason Burbage Mar 1 '12 at 18:36

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