In this case, there is a difference between what I would call legal and moral responsibility. Suppose you see a visually impaired person walking towards the edge of a cliff, blithely unaware of his existence. As for your legal liability, in general, you will not be able to successfully prosecute you if you do not warn him, and he continues to walk, falls from a cliff and dies. On the other hand, you had the opportunity to warn him - you were able to save your life, and you consciously decided not to do it. The average person is inclined to consider such behavior with contempt, judging that you had a moral responsibility to do the right thing.
How does this relate to this issue? Simple - the called party does not bear "legal responsibility" for the actions of the caller, silly or otherwise, for example, skips invalid input. On the other hand, when things go up, and it is observed that a simple check inside your function could save the caller from his own stupidity, you end up sharing moral responsibility for what happened.
Of course, there is a trade-off, depending on how much the check really costs you. Returning to the analogy, suppose that you learned that the same stranger is slowly approaching a rock on the other side of the world, and that by spending your life and warning him, you can save him. Very few people will judge you very harshly if you neglect this in this particular situation (suppose the phone was not invented for the purposes of this analogy). However, under coding conditions, if checking is as simple as checking for NULL , you shy away from doing it, even if the "real" one is to blame for the situation with the caller.
Stuart Golodetz Dec 08 '10 at 18:18 2010-12-08 18:18
source share