Debugging

Mayank Dhanawade
Technogise
Published in
2 min readApr 13, 2021

--

What is the first thing you do when you get an error? Or when your app crashes? Do you freak out? Do you just randomly Google things to find an answer? Do you get a hold of someone who might know the solution?

Why not take this slow?

Let’s take small achievable steps so that it feels less scary and fun to resolve.

Whenever we get an error we should divide the solution-finding process into 4 steps.

  1. Read the error. Yeah, I know you’ll be like dude c’mon what is this stupid step! But believe me, many times people don’t read the error and get anxious and the only thing that goes through their mind is “it’s not working”. So read the error carefully, it is very likely that you will understand the issue and resolve it then and there itself.
  2. Understand the error. After reading an error, does the error make any sense to you? Do you understand what is happening? If no, then look at the traceback, see where the error originated, and try to understand that flow.
  3. If 1 and 2 did not work, then now you search the error over the internet but don’t look for a solution; search that error to understand what causes that error. You can also search on Slack/teams, it might be possible that similar errors might have occurred earlier and people would have discussed it. It is very important to understand what causes the error because it will help you refactor and optimize your code and ensure that that the error does not come again. If you just search for the error and copy-paste the solutions presented to you, it is just going to be a patchwork. You don’t really want patchy code now, do you?
  4. Now that you have completed the above steps, let’s focus on reproducing the issue without making any changes, and let’s try to do it via tests (Test Driven Development). This should be a failing test; write a test that will reproduce that error, and then we make changes in our code to fix that error, based on our learnings from the above steps.

I know this might look like a long tedious process, but you learn so much from it! Not only do you learn about about coding, but it changes things psychologically for you as well. It reduces anxiety and increases patience, builds up confidence as well.

Once you have found a solution, don't forget to share it in your team’s communication channel so that it becomes discoverable for others in the future.

Do not try to achieve something big in one go. Take methodical steps towards achieving the goal.

--

--

Mayank Dhanawade
Technogise

Developer, travel blogger, wildlife and landscape photographer