Object reference not set to an instance of an object

Consider yourself in the position of a full-stack ASP.NET developer. You have interaction with your clients. At one point you get an email from your client saying: “When I clicked on that button it says ‘Object reference not set to an instance of an object’, in the dialog note”. First of all, the situation in which your client is addressing you with GUI terms (button, dialog etc.) is not right, but that is a whole another story.

Okay, so if you are beginner, you’ll google that message. That is going to lead you to nothing. If you are experienced, you don’t know what to think. Generally that error occurs when a null property is accessed. You probably made some try-catch block with handling either all exceptions, or just NullReferenceException. If you decided to make a logger, you can find stack trace there, but if you didn’t do that, you must go through code.

So, when you are doing code visual inspection, you know that some property, at some point is null. You don’t know which and, what is most important, you don’t know why. So after 2 hours of going through the code that you did or didn’t write, you decide to tell the client: “I can’t reproduce the issue. What exactly were your actions ?”.

So, you through the curve ball to the client. Remember, client is not an IT person, so the explanation of the issue is not going to be usable. Those kinds of exceptions are usually caused by some other actions that are setting property values that can be persisted or not. Sometimes you can’t rely on client’s explanation of actions.