42

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 , 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 tag - almost all the questions are closed as duplicates.

Looking at the 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 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:

Feature suggestion


(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.

14
  • Not germane to your question, but - you do realize it tells you how many questions are linked in the top right corner, right?
    – Makoto
    Commented Apr 14, 2017 at 13:55
  • (Forgot to look in the corner) Commented Apr 14, 2017 at 13:57
  • 3
    "Look at the nullpointerexception tag - almost all the questions are closed as duplicates" - makes perfect sense (it is easier to close question as duplicate by edit and tag it with "NPE"/"NRE" first and than close as duplicate), but very unlikely to be helpful for question's author when they post the question as they usually don't tag question with it. To my experience you'd edit and replace "YYY-studio" with "nullpointerexception"/"NRE" and change title from "Why editor YYY sucks and does not run my code" to something more sensible. Commented Apr 14, 2017 at 14:03
  • 1
    True, and it makes it a lot easier to close questions as a duplicate when they tag themselves with the post. But the goal is to prevent this many NPE questions from being asked, and thus reduce the size of the close vote pile Commented Apr 14, 2017 at 14:14
  • 1
    I'm in shock that this question is duplicated more often than How do I compare strings in Java? Commented Apr 14, 2017 at 14:55
  • Looking at the NPE tag, it is visible that most of thsoe who ask those questions have 1 rep. Meaning they don't think to do research of any kind. And as NPE's are a very common exception(and with no research, "really hard to fix") there are a lot of thsoe quesitons Commented Apr 14, 2017 at 14:58
  • @BilltheLizard: Makes sense to me; an NPE is a more apparent pain point/failure point, whereas string comparison is more subtle because it does work sometimes.
    – Makoto
    Commented Apr 14, 2017 at 15:16
  • @Makoto That's exactly why I would expect more people to be able find the NPE question than the String comparison question. Maybe there are a lot more questions about loop conditions and if statements not working that are caused by bad String comparisons, but they just aren't getting closed? Commented Apr 14, 2017 at 15:18
  • 1
    What I think is that those who do not know a programming language, and face an issue, tend to panic much faster than those who are more familiar with that or a programming language. The ones that know that crashes are normal, and the only thing to do is find out what it is(if not known) and fix it. Those who don't know what any given exception is, and think the crashes aren't normal(because "it worked in the tutorial") start to panic(or something similar), forget reason and ask on SO, Reddit, or any other forum that have these topics. Commented Apr 14, 2017 at 16:23
  • Relevant questions on meta: Can Stack Overflow notice a regular expression question and maybe suggest something apart from other like questions? (I could not find the original feature request) and Recognize synonyms of “regex” in question title (still not implemented)
    – Didier L
    Commented Apr 14, 2017 at 16:33
  • I'd say similar. I use regex as a point of reference because it is the only word I know of that shows a yellow(ish) popup telling the user to do extra research before asking. ANd it is helpful, I was about to ask a regex question once, but the dialog with the link to regex101.com helped me with it. Adding a dialog to NPE's, but also other things that have the same base cause(for an instance (with NPE's) making calls on a null object). That way we can avoid some (if not all) questions on that topic that are a duplicate of a main question(see NPE). And that reduces the close vote queue as well. Commented Apr 14, 2017 at 17:00
  • 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? Commented Apr 14, 2017 at 22:28
  • @JornVernee (sorry for late reply) adding a link for all the major programming languages with common pitfalls would also be awfully hard to do. But looking out a type of questions(NPE, NRE(C) and so on in Java, C and other languages) that almost always are closed and adding a suggestion to resources would be a good idea Commented May 15, 2017 at 13:41
  • Not only are the questions duplicates, they are useless duplicates. They don't have different terminology that by being recorded point to the canonical question. In all cases they are a no effort demand for us to do debugging for someone. No MCVE, sometimes no source code at all. No evidence of any debugging at all. Often it seems the asker has not bothered to even try to read the stacktrace. We don't need these garbage questions.
    – Raedwald
    Commented Jul 14, 2019 at 8:33

1 Answer 1

6

This appears to have been implemented:

enter image description here

(noticed when editing a question about a nullpointer)

You must log in to answer this question.

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