I'm playing with Pex and Moles and after running Pex found that nearly all the tests that Pex said failed were because NullReferenceExceptions were "allowed". Reading the Pex documentation, I came across the following:
If a higher-level component passes malformed data to a lower-level component, which the lower-level component rejects, then the higher-level component should be prevented from doing so in the first place.
So what the above is suggesting is that we should test for nulls before other methods/classes are called using something like:
if(foo == null)
throw new ArgumentNullException("its null and this shouldn't happen")
else
Bar(foo); //won't get a null reference exception here because we checked first...
IMHO checking for nulls all over doesn't appeal that much for performance and also code bloat reasons but I would like to hear what other people have to say....