8

Suppose there is a Stack Overflow question like the following:

What is wrong with my program?

I have a program like this, to ask the user to quit or continue:

public class QuitOrContinue {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String input;
        do
            System.out.print("Enter quit or continue: ");
        while (br.readLine() != "quit");
    }
}

For some reason this isn't working. Why?

The problem here is the way the input string is compared to the string "quit". There is a question How do I compare strings in Java? with useful information about this, but the question does not ask how to compare strings in Java. Is it better to close this as a duplicate, which happens quite a lot, or to contribute an answer that explains what is wrong and possibly provides a link?

2
  • 3
    That seems like a fair duplicate target, that's the question the OP is asking even if they don't know it Commented Oct 25, 2013 at 23:00
  • yes, I and many Java tag frequenters do this often. (although in this specific case I would close as "must demostrate a minimal understanding" because "isn't working" is not particularly helpful)
    – Doorknob
    Commented Oct 25, 2013 at 23:03

3 Answers 3

11

In an ideal world, no - you shouldn't do this, because they're different questions.

But this world is not ideal. That question is crap and should be closed anyway: the author fails to specify the problem he's encountering. You could vote to close as "unclear" or "Off topic - Questions concerning problems with code you've written must describe the specific problem..."

...Or, you could be nice to the guy and point him toward a question that, while slightly different, will actually solve his problem. Climbing down from that ivory tower we started out in, which of the actions I've described actually helps folks learn stuff?

Indeed, while multiple variations on a single question are... kinda ok, there's really no point in hosting 10,000 "Java P0rblem - halp!" questions on the site; at some point, you have to start helping folks identify the actual problem in their code or they'll never learn how to... Well, learn.

Joel wrote about this a few years ago:

Otherwise, the basic questions would just get asked again and again, and the old timers would grow bored and leave. The quality of the newsgroup would then deteriorate to approximately the level you would expect if seventh-graders were left to themselves, in other words, Lord of the Flies.

Yeah, folks can and do find thousands of different ways to ask the same basic question, again and again and again. Heck, even this question is a near- or exact-duplicate (see the list at the end of this answer). But that doesn't mean we should keep re-inventing the wheel every time someone new comes along:

When you see a question that seems like it might reflect a common problem, don’t just answer it to get a few points. That doesn’t make the Internet any better. Instead, help us build up a library of canonical questions and answers that are more generic versions of the same question, and then start closing all the exact duplicates.

All that said, be careful not to go too crazy with this idea. The example you gave was a very poorly-asked question with a very simple (and common) problem - it's easy enough to find another question that covers the same problem. But some problems are not so simple, and it can be harder to find an existing question that covers the exact same issue. In these cases, consider doing something else:

  • Edit the question to clarify the problem. Not only can this remove the need for it to be closed at all, it might actually make it easier for someone to find an existing, answered question that it duplicates. Heck, I've more than once found duplicates by scanning the "related" sidebar after editing to make the title actually reflect the question.

  • Post an answer that relates a different question to this one. I'm doing that right now (though with a blog post instead of a meta question as my source). Sometimes, it's hard for an asker to understand a solution presented elsewhere without something that relates the problem being solved there to the one they're having - a short answer that introduces, summarizes and then links to an answer elsewhere can provide the best of both worlds: a specific, focused answer to a semi-novel question and the refined knowledge of other members of the site, ranked and reviewed over the years.

See also:

5
  • 1
    There is no way you had time to read all that before marking it as accepted...
    – Shog9 Mod
    Commented Oct 25, 2013 at 23:57
  • In my opinion, the best answer is from a moderator, is 60 pages long, and uses every feature of markdown.
    – tbodt
    Commented Oct 25, 2013 at 23:59
  • How long did it take you to write that?
    – tbodt
    Commented Oct 25, 2013 at 23:59
  • 30 minutes, give or take. That seems to be about the limit to my focus today.
    – Shog9 Mod
    Commented Oct 25, 2013 at 23:59
  • 2
    @tbodt thats not really the way a community driven site works. This answer fully deserves the accept as being a very detailed answer, but not just because Shog9 is a moderator (or in fact community manager): Commented Oct 26, 2013 at 0:22
4

We want to be helpful. That is why we are here and answering questions. The desire to dup this to the real question is a very real one (that I've done myself - you don't know it, but you were really asking this other question).

However, this ultimately long term dilutes the quality of the questions that people search.

There are three key criteria to having the roomba act upon deleting a question as part of cleanup:

  1. No accepted answer
  2. Nothing with a positive score
  3. Not a dup.

That last one. Yea, not a dup. Dups are kept around as signposts for the "this question has a better answer over there". However, a question such as this "it doesn't work" and variations on that theme - poor question title, bad question text. Duping such a question to another one does two things:

  1. Clutters up the links to the question (that linked questions on the side)
  2. Prevents it from getting deleted through an automatic process

As such, its not serving the purpose of a dup. No one will find the question useful, and it will just sit there until a mod or three 10k'ers go and delete the question. This doesn't help anyone other than the original asker.

This again returns to the goal of Stack Exchange - making quality content for someone else to find (the asker is the seed of the content, but helping people who ask questions is a byproduct of the process).

Leave a comment in the question saying you have this other problem. Downvote the question for lack of research. Close it with minimal understanding as a reason. Let the roomba delete it in a bit over a week.

5
  • This is a very good point. It's certainly possible for auto-cleanup of dupes to be enabled for negatively-scored questions, though, should it become desirable.
    – jscs
    Commented Oct 26, 2013 at 1:09
  • @JoshCaswell If you know any other 10kers who would poke these things - this query is a modification of another one that I wrote, but this one looks for the dups instead of ones that aren't dups. If the question isn't a good signpost, well, thats up to you guys.
    – user213963
    Commented Oct 26, 2013 at 2:33
  • Probably worth remembering that only one of the automatic deletion scripts exempts duplicates...
    – Shog9 Mod
    Commented Oct 27, 2013 at 5:31
  • 1
    @Shog9 very true. Unfortunately between FGITW and the desire to give an answer, many dup questions have an answer (down voted it may be), but the scripts that don't care about dup status do care about that or 2+ comments. The query that I tweaked only lists low scoring dups that have (low scoring) answers. The automatic cleanup scripts would skip over these questions. With the parameters 0, 0, 100 - the one of the first results is stackoverflow.com/questions/6958069 which has 3x answers (0, -1, -1) keeping it from getting deleted.
    – user213963
    Commented Oct 27, 2013 at 18:55
  • Though thank you for pointing that out the "this would be deleted if not for the comments" is another thing to look for.
    – user213963
    Commented Oct 27, 2013 at 19:00
3

The important question to ask is; do the answers to that question answer the question, in this case they absolutely do so it's a good duplicate target.

This is ultimately the question they asked without realising it.

3
  • Really? I didn't know that.
    – tbodt
    Commented Oct 25, 2013 at 23:11
  • I remember asking in the comments when a similar question had close votes. I remember being told this then too. Commented Oct 25, 2013 at 23:39
  • 1
    I'm always a little more dubious when the answers contain the answer in amongst a whole load of other stuff, but here the answers are exactly what I would write anyway Commented Oct 25, 2013 at 23:55

You must log in to answer this question.

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