2. 1
Even if you have fixed something, it is
done without having reproduced the
original bug and having no idea what
you have actually done. So, always find
the exact steps to reproduce the bug. If
you can’t reproduce it, find someone
who can!
Always Reproduce the Bug Before You Start
Changing Code
Never just see the description of a problem, immediately make
some random assumptions, proceed to make changes in the code
cause soon you will find it’s not fixed.
3. 2 Understand Stack Traces
99% of time the stack trace will come
from a bad assumption in your OWN
code. Now it may not be that exact line
which has the bug, but you’ll need to
work backwards up through the code to
find where a bad argument was perhaps
passed in.
Therefore:
Always wrap exceptions thrown to you!
Not every bug will have a stack trace, but most of them
do. The key to remember is that the root cause, the
filthy culprit that broke your perfect day, is usually
wrapped up several layers deep.
So work from the bottom of the scary long stack trace upwards to find the
root cause!
4. 3 Know Your Error Codes
404 - You might have the wrong url in your app
401 - Your credentials are likely wrong
418 - You’re talking to a teapot!
(seriously https://tools.ietf.org/html/rfc2324)
429 - You’re making too many requests
Given how fundamental HTTP is to pretty much every
app these days, knowing what the HTTP error code
means can be a huge help in diagnosing bugs!
If you get an HTTP error code, always Google it to make sure you
understand it. Again, it’ll save you a lot of time! The same goes for
Database drivers and other protocols. If you see an error code,
Google it with the name of the database and look for the official
docs.
5. 4 Google! Bing! Duck! Duck! Go!
Whatever your search engine of choice is, you're sure to find a
helpful answer somewhere in the internet. Just gather up as
much information as possible before you hit "search" in the
search engine.
6. 5 Pair Program Your Way Out of It
Bring in a colleague, a friend (or a
CodeMentor) and talk them through it.
Show them the bug and the code, tell
them everything that you’ve tried and
explain to them what you think the
problem is. You would be shocked to
find out how often just the simple fact
that you’re talking it through and having
If you find yourself spending more than 30 minutes
hacking away and not making any progress, stop
right there!
to explain it to someone else can suddenly help you see what the
issue really is. Other times, it might actually be a complex issue (like
a race condition) and having a second set of eyes can help pick up
edge cases and scenario’s you have not even considered.
7. 6 Celebrate Your Fix!
Whether you turned a test
from red to green or closed
out a ticket on your queue,
give yourself a solid high-
five. You've just saved the
day and deserve all the
credit coming your way on
this one.