The premise of this question is wrong. This is a misleading question.
To put it bluntly, code is not "on" or "off" topic based on whether the code works or not. Not-working code can be on-topic. The critical aspect is actually clear in the help-center:
- To the best of my knowledge, does the code work?
This is not about working code, it is about what the asker of the question knows (or reasonably should know).
So, how do I explain this... If I have the following (Java) code:
public static void main(String[] args) {
System.out.println(args[1]);
}
Is that working code?
Well, that code will work if you supply two (or more) arguments to the program. It will throw an IndexOutOfBoundsException
if you have one, or no arguments.
So, that is code that may work. Now, why is this important? It's important because the significant feature of the question, when it comes to being on topic, is what the asker knows. Let's run through some scenarios for a question containing this code:
On Topic
I have this code that prints "World", and this is how I call it. Is it a good program?:
java MyClass Hello World
This is on topic because, despite being horrible code, the asker possibly never noticed that there is a bug.... and, since the code works for the intended use case, it is, "to the best of their knowlege", working.
Off Topic - known broken
I have this code that sometimes throws an IllegalArgumentException, and sometimes does not. This for example, when I run:
java MyClass Hello World
it works, and prints "World". How can I improve it?
This is off topic, because the asker knows there is a problem, and not only that, it is the top priority to get it fixed. That reason would actually make the question On-Topic on Stack Overflow, and Off-Topic here.
Off Topic - should have known
I have this code which prints "World" when I call
java MyClass World
Code that is presented for review that is obviously broken, and would not ever work, compile, or has some other fatal flaw, even in the intended use case, is code that the asker should have known was broken, even if there is no claim that it is broken, or even a 'lie' saying it works.
Off Topic - missing feature
I have this code that prints "World" when I run it like:
java MyClass Hello World of Code Review
but I want to extend it to print "World of Code Review".
This is code that needs to be modified to accomplish a task that is not there yet. The code currently runs, without error, but does not produce the desired result.
Summary
Code Review is one of the last steps in a process for creating quality code. It is expected that the code does its intended task before the code is ready to present for review.
If the code is not working as intended, and you know it is not working as intended, then the code is not ready for a review. If it fails, or occasionally fails, and you need help getting the code in to a reviewable state, there is Stack Overflow that can help you. If it works in a limited way, but does not accomplish the full desired feature set, then it is also not ready for review, and, depending on the problem, Stack Overflow, or perhaps Programmers may be the right place to go to for help.
If you think your code is ready for review, then you must also think that the code does what it needs to do, and it does it satisfactorily. Even if your thinking is wrong, the code, in your mind, was ready for review, and thus is on topic.
Bringing code to a review which is not ready for a review, and you know it is not ready for a review, is a horrible, mean thing to do, and it wastes time, and there is a special close and downvote button for those folk.
Bringing code to a review which you believe (in good faith) is ready for review, even if you are wrong, is forgiveable... with maybe a downvote, and a polite answer that points out why, would be nice.
Lying about your broken code, and claiming it works, when it does not work, is more than just rude .... hmmm. Not sure what the right punishment is for that.