« Javablogs.com | Main | hmmm »

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.

TrackBack

Listed below are links to weblogs that reference More Java pointers:

» NullPointerException from Feelings and Thoughts
It seems like I could link to kasia every time she writes something. Add her to your aggregator. I hope... [Read More]

Comments

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