6

Sometimes users fix bad grammar or spelling mistakes that appear inside the code itself. For example:

print "This number dont divide by ten"

Can be edited to:

print "This number doesn't divide by ten"

Sometimes there are mistakes in variable declarations, or method names - users tend to edit them as well.

I can see the advantages of those edits, but I can also point to some potential problems:

  • OP is simply being consistent with existing project variables / method names / etc...
  • An automatic script is expecting (by mistake) the output to be misspelled
  • ...

If I was editing the post, I would fix the formation, question's grammar and spelling, but I would never edit variable names, OP's conventions or the code itself.

Am I doing the right thing or should I edit minor typos / mistakes that in 99% (maybe) of the time don't harm anyone?

4
  • 7
    I don't see how editing the value of a variable is any different than changing variables names, re-styling OP's code etc... It should be avoided.
    – Jon Clements Mod
    Commented Nov 11, 2016 at 9:21
  • @JonClements I agree.
    – Maroun
    Commented Nov 11, 2016 at 10:41
  • 5
    @jonrsharpe That edit...
    – Maroun
    Commented Nov 11, 2016 at 10:42
  • @JonClements I've posted answer that you probably like to downvote - make sure to do so and possibly provide your own. Commented Nov 12, 2016 at 3:55

3 Answers 3

2

IMO syntax and typos should never be edited, unless is is something large such as code not being indented four spaces:

print "foo bar"

Should be edited to:

>>> print "foo bar"

That being said, there are definitely some typos or syntax errors that the OP does want fixing but such edits are better suited for comments in case the aforementioned edit messes with the OP's program in its entirety.

2

I think spelling/grammar mistakes in code should be fixed to maximize the response from the community.

Code with such mistakes would probably get less response for two reasons:

  1. Spelling and grammar mistakes make the code seem of lower quality.
  2. Spelling and grammar mistakes incur an extra mental load to reading and understanding the code.
1

It is perfectly fine to edit code to fix spelling mistakes, mismatched formatting, remove pointless comments and change bad variable names and other similar changes as long as code still demonstrates original problem (in the question) or solution.

There is no expectation that code is copy-paste ready or match some tool's input/output. Quite opposite - clean MCVE is desired (unlike CodeReview.SE where code must be exact production code).

I.e. it is perfectly common to cut type name in half to create variable name, but sometimes it makes code look childish - var ass = Assembly.Load("test"); and updating the name would make post more aligned with SO style.

3
  • 3
    I'd say that others should almost never edit a MCVE. The risk of breaking it is too much (unless you actually test that your edits keep it C and V), and renaming variables requires even more care: original name might be mentioned in question text, comments and answers, so changing it would make them confusing.
    – hyde
    Commented Nov 12, 2016 at 13:15
  • Even if we discount the possibility of "fixing" the code to hide the original error (which I've seen far too often), then I still say this is a bad idea beyond the most basic readability (e.g. maybe fix indentation, unless the file format has significant indentation) simply because it will make the code unfamiliar to the OP and will make answers harder to grok, even for future readers if there already are answers with the old code. Commented Nov 14, 2016 at 6:05
  • Also, changing a variable named ass? Sjeez. might as well rename string because my girlfriend wears a string ("haha"). I think it's much more "childish" to rename stuff like this. Commented Nov 14, 2016 at 6:07

You must log in to answer this question.

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