3

I came across this question which closed as containing insufficient information to debug:

Printing numbers in double for loop in Java

The question contains expected results and the problematic code, I guess it is closed because it doesn't mention the current "error" result. But in fact, the code provided can produce the problematic result in this case.

So my question is, can the problematic code treated as also provided "error" already if it can generate the "error" result directly?

2 Answers 2

2

It is a bit difficult for me to understand what this question is asking, but I think what you're asking is whether it's necessary for a question to explicitly state the relevant error messages, since the error messages could be obtained by merely running the code through a compiler.

The answer to that is yes, it is absolutely necessary that the error message(s) appear in the text of the question itself. This is stated in our guidelines for on-topic questions—namely:

Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example.

Notice the requirement that "a specific problem or error" be included "in the question itself".

If the question does not include this, that is grounds for closing the question for precisely the reason quoted above.

The reason why this requirement exists is that someone should not have to precisely reproduce your development environment in order to attempt to answer your question. If they're familiar with the technologies involved, they should be able to answer just by looking at your question. You want to make it easy for people to answer your question, not hard.


As for that question you happened upon, it merely says:

I'm stuck at how to decrement the last value by 1.

That is the entirety of the problem statement. It is anyone's guess where the asker is "stuck". That doesn't tell us anything useful. A guess is not the starting point for a good answer.

In this particular case, the task is simple enough that people can just solve the exercise themselves and post code, but that's not actually a good question. Stack Overflow is not a code-writing service, it's a Q&A site. Code dumps are not good answers. If an answer doesn't address the asker's specific point of confusion, then it is not a good answer.

The only possible hope for an answer to this question to meet our standards would be for it to explain in detail how loops and output work, but since the asker provided no starting point for his knowledge or hint as to where his confusion lies, the answer would essentially have to cover everything that an introductory programming text covers. That would make the answer far too long for the Q&A format, and thus the question too broad.

2

I would say no, the question cannot be treated as if it contained the error message.

It is true for all error related questions that you can get the error message if you manage to run the code. But you cannot be always sure, if the error message you receive is exactly the same as the error received by the OP. You can only assume. Only the OP can tell you that for certain.

Not to mention special edge cases, when the error is produced by the development environment and not by the code.

If in a specific case you are absolutely sure you found the error not disclosed by the OP, I would either ask in a comment for confirmation, or would describe the assumption in my answer. If the OP confirms the error, but forgets to update the question, then you can edit the question to include the error message.

You must log in to answer this question.

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