# Deep Java Thought of the day
null before using it, because that's what good defensive programmers do. So you start thinking real deep thoughts about what sort of Error or Exception to throw. The main point being that if the method gets given a null reference, there's no graceful recovery required. Just skreem and die.In a flash of brilliance, you realise that if you were to throw something called a
NullPointerException, you'd get the message across quite succinctly.Then you realise that this is what the JVM will do, anyway. So is there any worth to explicitly checking whether the object is instantiated or not, as good defensive programmers are wont to do?
And if you decide not to do an explicit check, then how do you make sure that the next person coming along doesn't just think you were sloppy? Do you start the method off with something like:
...
'Cause that could get really messy.
File under: java : {2004.09.22 23:23}