Often, questions about NullPointerExceptions (NPE) show up. 99.9% of the time, they are closed as a duplicate of this question. If you take a look at the "linked posts" tab of that question, there are 6811 linked questions. I haven't looked through all of them, but every single post on the first page is closed as a dupe.
When trying to write a question regarding regex, a yellow dialog pops up. It says:
A regex question?
First, please take a few minutes to…
- read the Regex wiki and What does this regex mean?
- search the most frequently-asked regex questions on Stack Overflow
- search Regular-Expressions.info for details on your specific regex engine
- and use regex101.com for explaining and debugging expressions.
Then, explain your question in detail.
That pops up when the title contains the word "regex". My suggestion is we do the same for NullPointerExceptions. As I already mentioned, 99.9% of the time, NPE questions are duplicates. I have only seen one question about a null pointer that wasn't a duplicate, and that was because there was an issue in IAB v3 (Android) that caused a null pointer.
Look at the nullpointerexception tag - almost all the questions are closed as duplicates.
Looking at the regex tag, there are much fewer duplicates. Although this may be random, it can also be because of that dialog showing possible solutions. By adding a yellow dialog to nullpointerexception submissions as well, it can reduce the number of questions that are marked as duplicates. Generally, adding the same if it detects i.e. a NullPointerException stacktrace (by the keyword java.lang.NullPointerException
)
Some suggestions of what to add to this dialog, can be the question I linked above (the NPE question most NPE questions are marked as a duplicate of), showing the Java documentation pointing to NPEs, and link to the NPE tag.
Why would adding a dialog help?
There is no guarantee it will work, but by showing any users with questions about NPEs these links, they may find what they need and thus not have the need to ask the question.
Looking through the NPE tag, it also becomes clear what language is mostly affected by this. The Android tag and Java tag are frequently seen. Looking through the front page of the NPE tag, a pattern can be found:
- Most users posting have 1 rep point OR;
- These questions come from users with <= 100 rep
It is rare that these questions come from > 100 reputation points users (but it happens), and those users may not be aware that they are supposed to do research before asking a question on Stack Overflow. So if a dialog is added on NPE questions, new users are given the solution to their problems. Whether they care or not is a different question.
To clarify, this is the feature I suggest is implemented on the NPE tag:
(Original statistics on question count: 5607)
When I asked this question, three months ago, the question NPE's are closed as duplicates to have more linked questions. Over three months, it gained over 400 new linked questions. I don't have a clue how many of these are duplicates, but I am assuming all. I also have no clue how many of the NPE duplicates are deleted, which would change the amount of questions. Other programming languages probably have the same exception, just with a different name.
Seeing as this already exists for regex, how many more of these feature requests are we going to need for the hundreds of other common pitfalls? I'd rather have a feature to do something like this on the fly, that is maintained by users. Maybe a tag (in this case [Java]) could have a link to a common pitfalls page?
Every tag has its pitfalls. The point isn't to remove them all (that would be near impossible). There are currently 8000 questions in the close vote queue. I don't know how many of those are null error references, but the point of the warning is to cut the amount of questions the review queue have to mark as duplicates when they are duplicates. Some NPE questions are deleted, and some are single handedly closed by users with gold medals, so some of these numbers are off. How much impact it could have is yet to be determined.
In three months, we assume there is 90 days. Over 90 days, there are (at least) 400 questions marked as duplicates.
On average, that means there is asked roughly 4.44 questions that are duplicates each day. Rounding that down to 4 questions per day, and assuming every one of these were passed through the close vote queue, that is 20 people (or less) who used a close vote (and a review in the queue (reviews in the queue are limited)). Meaning those 20 (or fewer) people can close a question that isn't yet another NPE duplicate. (It is 20 or fewer, because some may close more of the same questions, and some of the questions may be closed by users with gold medals) The point being 4 questions per day on average that are guaranteed to be closed in Java alone. Then there is C# with NullReferenceException, I don't have the statistics on daily average, but there are 3000 more duplicates there. Again, x questions per day, x * 5 or less, some deleted and so on.
I recommended adding the warning for nullpointerexception in Java and other languages with this exception, because these are most of the time duplicates. And each time it gets flagged, it goes into the close vote review queue and adds more and more questions that could be prevented from being asked. Again, it depends on how big an impact the warning would make on whether or not the question is asked.
The most important point with this dialog would be to try to prevent these questions from being asked and free up close votes for other usages.
[Java]
) could have a link to a common pitfalls page?