Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
We have had this question before; the NullPointerException is one of the commonest. Look at this thread from the end of last year. See whether it is of any help. There are several suggestions as to how to deal with such Exceptions. But what you ought not to be doing with most of at least these three Exceptions
is to catch them, because they usually represent errors in the program somewhere. No, you need to find out where they are occurring and prevent them.
NullPointerException means you have unintentionally forgotten to instantiate one of the objects, or (occasionally) have managed to destroy it without noticing.
...OutOfBoundsException means you haven't counted an array or String or something correctly and you are looking for a non-existent member.
ArithmeticException usually means you are trying to divide or "%" by zero.
If you ever have a method which deals with thoses situations and intentionally throws such an Exception, make sure you have a javadoc like thisCR
To avoid criticism do nothing, say nothing, be nothing. -Elbert Hubbard. Please critique this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss