I love NullPointerExceptions

I♥NPEThis evening a colleague phones up - he’s working at a customer site and getting in his words “the dreaded NullPointerException”, fairy nuff it’s a bug so not good, but why dreaded? The bug fixes I love are normally those where the stacktrace shows a NPE (in a class I have source code for) with a line number, normally from there you can easily find which object(s) have potentially been assigned a null value and backtrack to find where they were supposed to be allocated. Far better than some wrapped exception where the programmer has ‘helpfully’ masked the real problem. Of course once you’ve tracked down where the null is coming from it is a good idea to convert the code so that if null is not a valid assignment it either prevents the null result completely or complains then and there.

Tags: ,

Leave a Reply

You must be logged in to post a comment.