Where to check for null, in calling method or in function?

null

Should a check for null occur before making the call to a function or within the function itself?

Best Solution

I would say within the call itself. That way, you only check for null in one place, not 5 places if you call that function from 5 different spots.

But this isn't a for sure answer. It really depends on the function and what the consequences are of calling it with a null argument.