Skip to content

Did Java do us a favour, or no?

February 7, 2009

Gripe of the day alert!

In the old days, when I was a C programmer (when we were all C programmers), reading a null pointer was just about the worst thing you could do, apart from perhaps writing to one. Then along came Java – in many ways much nicer, it has a NullPointerException, so your program prints a nice message and doesn’t just core dump.

My gripe is that this fact has made people lazy. Whereas I used to be completely anal about checking pointers in C, I’ve become much more relaxed. I’ve noticed this laziness in my code recently and I’m going to change because…

A NullPointerException is not acceptable, EVER! (In my opinion of course). I hate getting them, whether in commercial software, in open-source software, in free software, or in my software. It tells you something is badly wrong, but rarely gives a user any insight into which of the million parameters that affect the running of the software is to blame.

One well-respected piece of open-source software was NPEing all over me recently and it was “right wracking me off”. Yes, I know I was fiddling around with it trying to get something obscure to work, and when I found out how to make it work, it didn’t NPE, but a well written piece of software doesn’t NPE, and if you’re calling an exposed API, then that API should be ultra-defensive.

Gripe off.

  1. Agree on this – defensive programming should persist, even if the application development language includes default catches for such errors, that does not mean the developer can skip such checks.

    btw, I’m using Adobe Photoshop Elements V6 and it frequently crashes in Windows with a null pointer. Puts me off upgrading to V7, as I seriously doubt they’ve fixed that sort of problem in the codebase.

  2. Matt permalink

    That’s pretty crummy!

    I don’t know who to attribute this quote to, I’ve heard it said many times and I’m a big believer in the fact that you can’t test-in quality, it has to be designed-in and built-in.

Comments are closed.

%d bloggers like this: