20

A recent question was asking how to find the longest word in a string using JavaScript. The asker posted some code which had a few errors in the for loop used to attempt to solve the question.

That question was closed as a duplicate of another question where the asker was also looking for a method to find the longest word in a string, but the reason their code didn't work was because they incorrectly subtracted one from the limit in the for loop condition.

However, this question was reopened by a gold badge user, saying that because the issue with their code is different, that questions are not duplicates if the underlying problem behind them is different, even if they are asking for the same thing using similar code.

Should the question have been closed?

5
  • 2
    "Duplicate" questions can still be found in search results, as far as I'm aware, so if the solution for problem A is the same as for problem B, then marking one as a duplicate of the other would mean that anyone searching for either A or B would find the solution they wanted, right? (Aside: Could you possibly provide links to the two questions in... question here so that we can see them?)
    – GoBusto
    Commented Apr 19, 2015 at 8:08
  • 7
    It depends what the question was. If they were asking "what's wrong with my specific code" then not a dupe. If they were just interested in "how do I do x" then probably a dupe. Commented Apr 19, 2015 at 8:12
  • @GoBusto stackoverflow.com/questions/29726713/… and stackoverflow.com/questions/17386774/… are the two specific examples that prompted the question, however I was thinking of the more general case. Commented Apr 19, 2015 at 8:12
  • Javascript eats the world. Well over half of the programmers have no formal education, writing a for-loop is a challenge for them. Follow that link, that's a major investor in SE that has a vested interest in these kind of questions getting answered. It improves his bottom line in a big way, cheap labor and experts that don't mind out-sourcing their job, what is not to like? Commented Apr 19, 2015 at 13:20
  • 7
    The rule of thumb always have been: if all possible answers to A apply to B and all possible answers to B apply to A, both are duplicates. The fact that the same solution can fix two wildly different problems with different causes, doesn't make them duplicates.
    – Braiam
    Commented Apr 20, 2015 at 0:09

1 Answer 1

24

As far as I can tell, in this case, the two questions weren't of such good quality: the older one could also have been closed as a "simple typographical error", but it's good to see that it was correctly solved anyway. In the second question, the OP was trying to achieve the same exact result, but their issue was a bit different.

The problem here is: should we close questions as duplicates even if the particular issue to achieve the same result is different? Well, Stack Overflow's main purpose is to create an online Q&A archive of solved questions so that future users (and hopefully whoever searches the web) will be able to find them and quickly solve their problems. Now put yourself in the shoes of a regular user searching for a way to find the longest word in a phrase, like these two questions are asking: you will obviously search the web for something along the line of "find longest word in a sentence javascript". Then there are two possible scenarios:

  1. We didn't close the other questions concerning the same purpose because of their little coding (and related issues) differences: you'll then find a bunch of similar questions, getting confused looking for the one which fits your needs.

  2. We closed the other questions as duplicates, and you'll easily find the only (original) one without any trouble.

In my honest opinion, we don't actually want (nor need) the first scenario to happen. Instead, our goal should be to provide the best solution to the problem, and close any other following question about the same issue as a duplicate of the well answered older one. The newer question should then be rephrased to represent a different (and not duplicated) issue: there's still chance for someone to search something like "infinite for loop javascript issue".

In conclusion, as said by Anthony Grist: the key point is that people coming from Google (or anywhere else) don't actually care which problem somebody else faced while trying to achieve the same goal.


Notes

This hasn't got to be taken as "the holy guideline" in any case. It's clear that there are infinite possibilities when talking about duplicated answers, and it's complicated to find an unique solution for all of them, but common sense can solve anything, and there's always the option of drawing moderators' attention in edge cases.

2
  • 3
    The key point being that other people coming in from Google don't care what problems somebody else faced while trying to achieve the goal. They just want a function that will give them the longest word in a string. Commented Apr 20, 2015 at 13:05
  • @AnthonyGrist thanks for the comment, I added it to my answer Commented Apr 20, 2015 at 13:12

You must log in to answer this question.

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