«« Next » « Previous
«« Next » « Previous

Link Details

Give a link some love! Login and vote now.
Link 65787 thumbnail

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.
  • 12
  • 2
  • 1630
  • 938

Comments

Add your comment
User 270428 avatar

mcmohd replied ago:

0 votes Vote down Vote up Reply

Good article. I liked it.

User 236137 avatar

dzonelurker replied ago:

0 votes Vote down Vote up Reply

"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!

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.