I'm following along on this question, and Andrew Thompson simply removed the OP's sample code whole cloth. His (somewhat belligerent) comments suggest that since it doesn't compile, it's therefore not the code the OP is using, and it's thus worthless and a waste of people's time.

I disagree and think that removing the code we are analyzing is a much bigger waste of time. What should be done in this situation?

(And I know the question to which I refer doesn't really belong on this site and perhaps should be closed anyway -- I still don't think this practice is appropriate though.)

  • 1
    The title of this question is somewhat misleading. The problem isn't that the code doesn't compile; the problem is that the posted code differs from the problem code. The fact that it doesn't compile just happens to be the reason we know about the discrepancy. – Pops May 18 '12 at 22:49

After I read this question, I agreed with you, but the editor has a point. The OP of the SO question said that his code worked, but the code he posted didn't even compile. Therefore, the code he posted isn't the code he was using.

He later admitted as much in a comment:

I'm sorry for that, I have modified the source since I compiled it. Nothing too major should be changed

I'm not accusing him of anything malicious, but he's obviously confused — he's asking a question on SO, after all — so it's probable that some change that seemed minor to him actually had major effects.

This should probably be analyzed in the general case, though, not this specific one.

On the one hand, providing some code is certainly better than providing no code. Even non-working code gives a basic idea of how the asker is approaching the problem. However, if we don't know the differences between the code the OP used and the code the OP posted, it's going to be hard for us to solve the problem. If we find an issue, is it the one that caused the problem originally, or something that was introduced afterwards? In this sense, posting changed code is not that different from "I need to do X in Java. Here's some Haskell code that solves another problem entirely."

  • Nice answer, but specifically -- shouldn't the OP's code remain? Isn't it better than nothing (as you said)? – Kirk Woll May 18 '12 at 22:43
  • 1
    I guess it should remain, but with the understanding that it's just a placeholder. The OP should be encouraged to replace it with the original code. Even better would be an SSCCE, but when you're already facing a confusing problem, figuring out how to create an SSCCE can be nearly impossible. Alternatively, I guess the OP could reword the question to fit the new code, but I'm having a hard time imagining a situation where a question about non-working code is better than a question about working code. – Pops May 18 '12 at 22:51

You must log in to answer this question.

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