What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 133 Stack Exchange communities.

Take questions like this one for example. The code is terribly written, and the question is a poor one but still a question. Say I couldn't answer a question like this, but I could still correct the code. I take it that code corrections shouldn't be posted as an answer, because it's not an answer to the question. Nor should they be edits, because it's possible that the original intent would be lost, and it's not semantically an edit, either. Normally I'd post some fixes in the comments, but in this case, the corrections were much too many to put there.

So... where should I put something like that, then? It would be so wrong not to point something like that out. Luckily I could answer that one, but what if not...?

share|improve this question
    
I ask them to fix their mess and give them a link to the formatting help page: stackoverflow.com/editing-help –  NullUserException อ_อ Nov 29 '11 at 4:12
    
@NullUserExceptionอ_อ: In this case, though, I don't mean formatting - the code is terribly written and hard to sift through. –  U2744 SNOWFLAKE Nov 29 '11 at 4:17
3  
People seriously need to stop to copy code from The Daily WTF and use it in production...I'm tempted to send that in... –  Time Traveling Bobby Nov 29 '11 at 8:11
    
@minitech, if the code really is terrible, just post an "answer" with your take of how it should be written. It should be of help to OP. –  vonbrand Feb 26 '13 at 2:04

2 Answers 2

up vote 9 down vote accepted

Your answer is this

I take it that code corrections shouldn't be posted as an answer, because it's not an answer to the question. Nor should they be edits, because it's possible that the original intent would be lost, and it's not semantically an edit, either.

If it's not an answer, don't post it as one. I understand the desire to help someone write better code. By all means, encourage him to do so. While you cannot provide full code refactoring to code blocks like those in the question via comments, you can certainly use comments to mention strategy or techniques that are useful, or links to various blogs or resources that can start somebody along the path to writing better code.

You could also prod the user that, if he is interested, that once he gets the code working, to take it to the Code Review site for suggestions on how to make it better.

But unless you are addressing the actual problem at hand, do not use the answer box. While it is an attempt to generally help, it is not specifically helping solve the problem and is therefore noise.

share|improve this answer
    
If you're referring to my answer, I fixed the problem too so it is an answer. :) But thanks, I suppose I'll direct people to Code Review. –  U2744 SNOWFLAKE Nov 29 '11 at 3:33

Fix at highest the whitespaces and superfluous lines from large code blocks --only when you're 100% confident that they're completely unrelated to the concrete problem. Do not change the class/method/field names nor the code flow.

I usually answer with an edited/improved copy of the question's code, if necessary along with a side note, hoping that the questioner understands the hints. If the code is really that terrible, I add another unrelated note after having given the concrete answer to the concrete question.

If you have right now an irrepressible tendency to review, improve and rewrite other's code, take a pause at http://codereview.stackexchange.com.

share|improve this answer
4  
And please for the love of everything, for anyone who stumbles upon this meta question — don't edit a post just to move opening braces. –  BoltClock's a Unicorn Nov 29 '11 at 4:12

You must log in to answer this question.

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