Archive for October, 2008
what to do for nulls
October 17th, 2008 by Jeanne BoyarskyA logical follow up to null checking in the extreme and Never return Null Arrays, is what we should be doing when a null does get returned. The problem Consider the following method: This time, a null check is appropriate because we can’t guarantee createBuilder() works as advertised. Let’s assume that the method is either [...]
Posted: 17 October, 2008 in Development Process.
Comments: -
Never return Null Arrays!
October 15th, 2008 by Scott SelikoffContinuing on Jeanne’s theme of nulls, its a pet peeve of mine when I come across code that returns null arrays instead of empty arrays. The purpose of this post is to discuss some of the reasons why its a good practice to return empty arrays over null arrays, including Collection objects or typed array. [...]
Posted: 15 October, 2008 in Development Process.
Tags: array, Java/J2EE, null, NullPointerException
Comments: 7
null checking in the extreme
October 13th, 2008 by Jeanne BoyarskyIn Java, we’re told to check for nulls to avoid unexpected null pointer exceptions. This can be taken too far though. Consider the following code: When did builder have the opportunity to become null? By definition, a constructor creates an object. We just called the constructor. We know builder isn’t null. Having extra code around [...]
Posted: 13 October, 2008 in Development Process.
Tags: Java/J2EE, null
Comments: 17
