Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 158 Stack Exchange communities.

What is meta?
Here's how it works:
  1. Any Stack Exchange user can ask a question
  2. The community provides support, votes on ideas, and reports bugs
  3. Your voice helps shape the way Stack Exchange operates

I regularly see SO questions with HTML/CSS/JavaScript code that is not optimal and that could be reformatted. Sometimes I just comment my suggestion, but sometimes the suggestion is to elaborate to be put inside a simple comment.

In those cases, I was thinking of using an answer but marking it CW. Is that a good approach?

Ideally, one should be able to suggest code optimization without having to answer the OP's original question. It would be cool if each SO question would have an cw area where users could suggest code optimizations, and generally propose best practices.

share|improve this question

Reformatting should just be edited into the question.

Code optimization should be put in comments, and if it's too extensive for a comment, but yet doesn't answer the question, then you should probably just leave it alone.

share|improve this answer
So, you're saying that if the OP posts a large section of code, and I wanted to suggest code optimizations (in the spirit of spreading knowledge about programming best practices), that I should just leave it alone? That doesn't sound right. – Šime Vidas Dec 15 '10 at 17:17
@Sime, yes, it your code optimizations (which I always want to know about myself) won't fit into a comment or 2, then posting an answer with them would really be hijacking the question. Maybe just leave a few of things that should be done, instead of hitting every point. – Lance Roberts Dec 15 '10 at 17:20
Yea, you're probably right about that. – Šime Vidas Dec 15 '10 at 19:26

I don't think you should mark it as CW - If improving the structure least to an easier solution, you're suggesting a proper answer. The OP may not be aware better options exist, and it is very common to point out alternatives.

share|improve this answer

This isn't a discussion forum or code-review site.

You're writing for more than just the OP. He'll read your answer (or not), vote on it (or not...) and move on; your answer will remain for others to read and learn from.

So if you don't answer the question, then you risk wasting the time of numerous future readers, regardless of how useful your comments might be to the original asker!

And heck, for all you know he scribbled in a quick bit of code just to illustrate his problem, and it bears no resemblance at all to his real work.

Now, that doesn't mean you shouldn't write anything that's not absolutely needed to answer the question... But by jumping in to critique style (when the question isn't about style) or suggestion optimizations (when the question wasn't about performance) you're generating noise. And by posting such comments in lieu of an answer, you risk driving away other answerers (who'll see that an answer has already been posted) without giving the OP anything he asked for...

I'm not saying don't do it. But be very, very reluctant.

share|improve this answer
Makes sense. But I don't agree that code in SO questions is scribbled in a hurry. I think that in most cases, it's the actual code that the OP is using in his project. – Šime Vidas Dec 15 '10 at 19:25
@Šime: my point is that even for the one reader who might benefit from your advice, you can't know. – Shog9 Dec 15 '10 at 19:28

You must log in to answer this question.

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