Find the Root Cause

Debugging is tricky business. You really have to act like a detective and sift through all the clues to discover why your program isn’t doing what it is supposed to do. As you search for the problem, you will often find many symptoms, and you will be tempted to fix those symptoms. I have done this many times, and not once has it been a good idea. Keep digging until you find the root cause of the problem—when you fix that root cause, you will fix all the symptoms at once. A good indication that you are fixing a symptom instead of the root cause is that the fix makes your code messier and harder to work with. For instance, if you have to add a new parameter to one of your functions, you are probably fixing a symptom and not ...

Get Learning to Program now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.