Introduction

Finding bug in code, is a process of confirming the many things that we believe are true — until we find one which is not true.

—Norm Matloff

Debugging is like being the detective in a crime movie where you’re also the murderer.

-Filipe Fortes

Strategies for finding and fixing errors

Google!

Whenever you see an error message, start by googling it. We can automate this process with the {errorist} and {searcher} packages.

Make it repeatable

To find the root cause of an error, you’re going to need to execute the code many times as you consider and reject hypotheses. It’s worth some upfront investment to make the problem both easy and fast to reproduce.

Figure out where it is

To find the bug, adopt the scientific method: generate hypotheses, design experiments to test them, and record your results. This may seem like a lot of work, but a systematic approach will end up saving you time.

Fix it and test it

Once you’ve found the bug, you need to figure out how to fix it and to check that the fix actually worked. It’s very useful to have automated tests in place.