Ten Questions To Ask Yourself When You Debug < … >

Ian Khor
dev <tech> tips & tricks
4 min readDec 12, 2016

--

I was searching for an article about the ways to debugging software and couldn’t find one for my coding classmates. So I’d thought I’d write one myself, drawing from prior experience in writing software/firmware and designing electronic hardware. Hopefully, this will be a starting point for you to develop debugging skills.

For newcomers to the world of tech, it’s sometimes hard to know where to begin. Before we can solve problems, we have problems to solve setting up and using the tools that we use to solve the problems! What a paradox! It’s worth it though, because we then have the opportunity to solve interesting world problems, commercial or otherwise.

The first step to solving the problem is understanding that computers run fast. Really fast. To debug, sometimes we have to be like Neo, with the ability to see things or think as fast as the bullet speeds. This brings us to our question, which i called

‘Think Bullet Time’:

What is the computer doing, step by step, to achieve what I see on screen ?

Think bullet time. Be The One.

To answer this question, I need to work out how to see what the computer is doing.

The following is a short list of questions that have guided me through my debugging experience. While it is not definitive, it hopefully can provide some advice on how to proceed in debugging in a more structured manner.

1. Is my setup or configuration correct ?

Development tools often come with documentation or datasheets. Spending 5 minutes reading through them and making sure that you have set it up correctly would solve a majority of your problem initially. If things doesn’t work, have you read through the documentation ?

2. Did the debug log tell me what the actual problem is ?

Don’t be overwhelmed with the many lines of debug logs. They may seem scary but they are actually here to help. Most of the time it actually tells you what and where the actual problem is ! Spend 5 minutes and the trick here is ‘Think Bullet Time’. What caused that error ? How was the error triggered ?

3. Am I in the right folder ?

As simple it may seem, with so many things going on in development, are you in your working folder?

4. Is it just a syntax or spelling error ?

Sometimes its just as simple as a syntax error, you may have accidentally omitted a bracket or closing brace. Sometimes it could be just a spelling error. For example for the HTML DOM property — textContent — can be mispelt as — textContext — . See the error ? When we are reading through code, they make perfect sense because they are spelt correctly !

5. Have I passed or received the right datatype ?

When you pass elements/data around in your program, are you receiving and passing what you have expected ? For instance, you are trying to fit a spherical ball into a square-shaped hole. In software jargon, your function is expecting an integer but you have passed an array. A sanity check would be helpful sometimes.

6. Have I passed the right number of arguments to my function/method ?

Similar to Question 5, you might be passing the incorrect number of arguments around.

7. Is my data computing correctly when I used iterative methods / logic ?

You may have a collection of items (i.e. array) and you perform iterative methods on them such as for, while , do loops. Let’s do a Neo. ‘Think Bullet Time’, try and display on screen or your debug console whether are you performing the logic right for each item one step at a time.

8. Have I tried injecting definitive code/data intentionally and see what I would expect on screen ?

You have added a heap of code but still you don’t see the output you want. That could be frustrating. So the question is, is your code actually executing ? You may have written conditional (ie: if or switch) statements but are they actually being executed ? Injecting simple code like printing a simple “Hello world” in your conditional statement may help you see the flow of your program execution.

9. Have I tried commenting off code to isolate the problem ?

Sometimes you add a new function and something breaks. Have you tried commenting off code to see which line is causing the problem. A line by line approach in commenting off code may be feasible but it is not the most effective way. But that may be a path to follow if you have ran out of ideas on what the problem is.

10. I still have no idea what is wrong, have I used a pen and paper to draw out what is happening ?

As humans we are highly visual animals. At least I know I am. Sometimes when I really have no idea what is hapenning, I would step back, take a deep breathe and try to get a birds eye view of what is happening. A little old school but sometimes with just a pen and paper, we free up our minds from all the technical bits and just use what comes naturally to us — A pen and paper — and see visually how things work. Just draw it out. That’s why engineers have top level or system diagrams !

So hopefully the above would help you in some way getting closer to solving your problem. And lastly ‘Think Bullet Time’.

‘Think Bullet Time’ and you may be The One.

--

--

Ian Khor
dev <tech> tips & tricks

Web app developer, electronics engineer, business analyst & designer at heart. Concept, design, build and commercial acumen.