Give a link some love! Login and vote now.
By mswatcher
via basilv.com
Published: Feb 13 2008 / 06:24
One fairly common coding style I have seen from more experienced developers is what I will call highly-aggressive null checking. Such developers have most likely been burned by null pointer exceptions in the past and hence have evolved a style of coding which confirms that parameters or fields are non-null before using them.
Comments
mcmohd replied ago:
Good article. I liked it.
dzonelurker replied ago:
"One fairly common coding style I have seen from more experienced developers is what I will call highly-aggressive null checking."
'experienced developers' don't check for null.
"it results in more robust code than code that ignores null checking completely"
it doesn't
"My coding style instead uses precondition checks "
Wrong again.
When the caller passes a null reference where a reference to an object is expected then the caller (and only the caller!) is responsible for the NullPointerException. Never check for null in your code, it makes no sense!
Voters For This Link (12)
Voters Against This Link (2)