We had a situation today regarding this question. (See also the timeline).
- The submitter asked a question with a code excerpt only, without making a compileable minimum working example (MWE).
- The question was edited and some fluff was added to illustrate the problem (full disclosure: it was me who did the code edit changes).
- Someone added an answer based on the MWE.
- Turned out that the proposed solution was breaking other things (that the OP didn't mention, so the real document had to be referenced via a link to figure out what's really the problem).
- A completely different solution was offered that solved the issue the submitter had.
If the submitter had made an effort to create a MWE the extra work could have been averted (I apologize to Martin Scharrer for the time he had to spend on this).
Now the question is:
Should incomplete code be edited in the question for the benefit of the user (and potential responders), or should this be the sole responsibility of the original poster?
I see a few pros and cons for editing user's code:
- Most of the time it works, and everybody's happy.
- The edit might be just what's needed to attract some quick replies, as the code can be copied and compiled without modification.
- No time is lost in back-and-forth communication between the OP and the potential editor.
- No duplicate posts (there has been a similar situation recently, when a new user didn't notice they can edit their own posts, and created a duplicate, which was promptly closed).
- When it doesn't work, this results in some extra effort to people trying to solve the wrong problem.
- Time is lost when figuring out what's actually wrong, which could have been averted if the OP was asked to provide a MWE by themselves.
- Original submitter might be frustrated that people meddle with their stuff, playing "smart guy" (although with good intentions).
Personally, I think the extra editing helps in most of the cases, but when it fails, it does spectacularly.
Edit: It seems most think that it shouldn't be done in general, or if done, should be careful and clarified. Although I reserve a somewhat dissenting opinion, I understand the arguments of everybody, and will refrain from such editing in the future.