Via slashdot, the inventor of the null reference has second thoughts:

But I couldn't resist the temptation to put in a null reference, simply because it was so easy to implement. This has led to innumerable errors, vulnerabilities, and system crashes, which have probably caused a billion dollars of pain and damage in the last forty years.

I am not a fan of null. It is a compiler level issue which has made its way into business and presentation logic; where it has no place. I would like a dollar for every time I have cleaned up a NullPointerException or littered my code with null checks.

The Problem With Null

This is from an email that was sent to me by the Australian Democrats. They are doing the right thing and seeing who on their list is interested in being maintained on a subscriber list. The problem is the NULL value in the 'Dear NULL' line.

One of the things I hate about Null is that it is a compiler level issue that has somehow propogated to databases and nearly always ends up at a customer level because it litters presentation logic. There is no way that the end user of this email should even/ever be faced with the word Null.

In my opinion it is a fundamental flaw in software engineering that this problem still persists. No wonder the inventor of null wished he had not.
Kathryn: Hi Cam - firstly as the person who hit send on the email - sorry about that.

The problem was that on around 1200 records in the list of 36,000 someone had put NULL in to the name field. Had it been blank it would have said 'Friend'. I have fixed it all now... but if you'd like to email me from your email address so I can track you down in the system I'll put your name in so the next one says 'Dear Cam'. :D
cam: Hi Kathryn, I didnt mean to single out the Australian Democrats, it is a pet peeve of mine in software engineering how a low level issue like that is geared - by the structure of software tools and development methodologies - into presentation logic and a data state that is only meaningful to a software developer becomes one of perplexity for the end customer.

One system I worked on was endemic with NullPointerExceptions being blasted out to customers - stack trace and all. Usually front-end engineers have to clean up the mess that back end engineers make with their 'throw runtime exceptions' philosophy that gets around java's default state of checked exceptions. IMO software engineering has failed when these get to the customer.

Cast a Null in Java

I was working on unit test today to do with getSingleResult() from the EntityManager's query interface. I set the test up to check no results and then an outside exception. I had the query.getSingleResult() mocked to a null and got a surprising result.


context.checking(new Expectations() {{ allowing(query).getSingleResult(); will (returnValue(null)); }});

It wasn't dropping into Exception as I expected. To my ignorance I was expecting a ClassCastException but in Java (and C#) null can cast to a type. I modified the test so that it did what I wanted and then went searching to see why you would want to cast a null.

This seemed to return the best answer. I still am not sure why it is a good idea to cast null, but in the case of method over-loading, it will ensure that the correct method is hit when passing in nulls as arguments.

Most Popular on South Sea Republic

The articles that have been viewed the most:

Most Popular Restaurants in Phoenix

Phoenix Eats Out is the restaurant review site for Phoenix, Scottsdale and Old Town Scottsdale which lists the modernist and contemporary restaurants, taverns and bars in the greater Phoenix area. This is the list of the most popular restaurants pages from phoenixeatsout.com that have been viewed the most; My personal favourite restaurants in Phoenix are AZ88, Postinos, Bomberos with Grazie, Humble Pie, Orange Table, The Vig, Fez and others coming close behind. View the complete list with the photo-journalistic style images on phoenixeatsout.com

Most Popular Hikes in Arizona

Arizona is an outdoor state and has lots of hiking in the city and around the state. Phoenix is unusual for most cities in having several large mountains in the center of the city with great hiking. Anyone who comes to Phoenix has to do the Echo Canyon trail on Camelback and the Summit Hike on Squaw Peak or Piesta Peak. The views of the city, suburbs and surrounding mountains are wonderful from Camelback and Piesta Peak. For more experienced hikers there is the McDowell Mountains in North Scottsdale that has several difficult and strenuous hikes in Tom's Thumb and Bell Pass. Alternatively, you can hike the highest mountain in Arizona. At 12,600 feet Humphrey's Peak is a long and difficult hike.

Alternate Australian Constitutions

Between 2004 and 2009 this site, southsearepublic.org, was a constitutional blog based on scoop which focused on Australian and global constitutional issues. One of the strongest aspects of it was the development of constitutions by those involved in the blog. These constitutions are the outcome: The constitutions were built using principles from Montesquieu's separation of powers, the enlightnment's universal political rights and the ancient Athenian technology of sortition and choice by lot.

Archives For South Sea Republic

South Sea Republic started in 2004 as an Australian constitutional blog in 2004 based on scoop software. It was an immigrative outgrowth of Kuro5hin. The archives for each year since then; The articles are ordered by views.

Who Is Cam Riley

Cam Riley I am an Australian living in the United States as a permanent resident. I am a software developer by trade and mostly work in Java and jump between middleware and front end. I originally worked in the New York area of the United States in telecommunications before moving to Washington DC and working in a mix of telecommunications, energy and ITS. I started my own software company before heading out to Arizona and working with Shutterfly. Since then I have joined a startup in the Phoenix area and am thoroughly enjoying myself.

I do a lot of photography which I post on this website, but also on flickr. I have a photo-journalistic website which lists the modernist and contemporary restaurants in phoenix. I have a site on the Australian Flying Corps [AFC] which has been around since the 1990s and which I unfortunately lost the .org URL to during a life event; however, it is under the www.australianflyingcorps.com URL now. The AFC website has gone through several iterations since the 90s and the two most recent are Australian Flying Corps Archives(2004-2002) and Australian Flying Corps Archives(2002-1999) which are good places to start.

Websites Worth Reading

Websites of friends, colleagues and of interest;