Fix bugs like a Pro - Simple steps to tackle errors as a software developer and be productive.

ยท

4 min read

Fix bugs like a Pro - Simple steps to tackle errors as a software developer and be productive.

Introduction

Very often as developers, we come across a series of errors during software development and testing, and most times, we get stuck for hours and maybe even for days trying to solve them. No one likes bugs, they hinder our productivity and demoralize us.

In this post, I list below and explain tried and tested methods to solve these bugs, make our project managers happy, and learn in the process, while remaining productive.

Step 1

Relax, read, and understand the error message, the answer might just be there. As a new developer, it's easy to get overwhelmed when you come across error messages that span several lines. Don't fret, take a deep breath and read the lines carefully. Look for keywords that might point you to where the error might come from (line numbers, functions, e.t.c) This step should take a maximum time limit of 2 minutes

Below is an example showing a simple error message about a missing export in the package.json script for a Next Js app err.PNG

Step 2

Tinker/Experiment, this is the obvious next step. After reading the error message, some error messages are straightforward, while others are more obscure. This step involves looking at your code and checking for syntax errors, misspelled words, and the flow of function/method calls.

Move things around based on what you suspect, comment out parts of the code and run the code again, try to find and isolate the buggy part, then work your way from there. Note, Tinkering should be limited to a maximum time limit of 10 minutes, if you've elapsed the time, move to the next step.

Step 3

Google it. If you are a developer, google is your best friend, that friend that's always beside you, giving you advice and telling you how to face your problems. Everybody googles, from newbie developers to highly senior developers.

For this step, copy the error message, or, if it's too long, parts of the error message and just paste it into the google search box, and click search. 70 percent of the time, you'd get your answers or hints to where your bug is coming from. and how to resolve them. Limit time spent in this step to 10 minutes. If the time elapses and you've not found a solution (which I partially doubt), see the next step.

Example of googling for a solution ge.PNG

Step 4

Ask questions on stack overflow. If you are a developer, you probably have a stack overflow account. If you don't, please go create it now Here Before you ask questions, be sure to read the community guidelines, and please format your questions well to show that you've done a bit of work trying to figure out the problem yourself before you came there. Be sure to include code samples/parts of the code you suspect the error comes from.

You could also ask questions on the forums, discord channels, or GitHub issue/discussion community for that particular technology you are working with. Note, this step might not give answers immediately as these are people that answer these questions, and have daily jobs that keep them occupied. While waiting for answers from these channels, go to the next step

Step 5

Check the docs. There is a high probability that the issue you are facing has been mentioned in the documentation for that technology, and you would not be facing it if you had just paid a little attention to the docs.

These days 90 percent of the technologies we use have their documentation, to get them, it is as easy as typing into google the "[technology] documentation" e.g " react documentation" or "Nginx documentation". Go to the search box in the documentation and search for specific areas or keywords you came across in your error. You might be lucky and the answer was just right there in front of you, just a click away. Limit time spent on this step to 15mins

If at this point, you still can't find a solution to the bug, which I highly doubt, I suggest you find a bed and take a quick nap, then look come back to it after your nap, the solution might just have come to you in your dream.๐Ÿ˜‚

Till next time.

ย