January 10, 2003
More Java pointers

To go with my previous entery about pointers "The Fishbowl" has his/hers own entry on the same topic.. both inspired by Jeremy's adventures with Java.

The part I really want to reference is this section:

  1. Before you start writing a method, decide whether it will ever return null. Document this decision in the @return section of the method's Javadoc.
  2. Never have a method return null unless there's a really good reason for it.
  3. If your method returns an array or a collection, there's no reason to ever return null. Return an empty array or collection instead.
  4. If you have a situation where null is a valid value for a variable, you can make use of the Introduce Null Object refactoring, to make the behaviour explicit.

That's very good advice.

Posted January 10, 2003 08:25 AM in Java
TrackBack URL for this entry: http://www.unix-girl.com/mt/mt-tb.cgi/481
Comments
On October 21, 2003 11:01 AM prathap added:

in java how can i create variable naming by using the content of another variable at run time ie dynamically,

#
Trackbacks
Feelings and Thoughts:NullPointerException
It seems like I could link to kasia every time she writes something. Add her to your aggregator. I hope...
(read more)
August 26, 2004 05:29 AM