Software Debugging — My Learnings

Omkar ShetkarOmkar Shetkar
3 min read

Recently, I needed to debug an issue occurring in a staging environment. We had no direct access to logs, so there was no way to see live logs; we could only view past logs captured some time ago. Given the distributed nature of the application, it was difficult to pinpoint the root cause of the issue without seeing it in action. Finally, after a couple of days of repeated log capture and analysis, we identified the scenario causing the issue. Finding a reproducible scenario is half the battle won.

Debugging is such an important skill, yet it is underrated. It is undervalued in academia and in interviews. It is a skill the software developer develops over years of experience. I started my software development journey in 2005. I have worked mainly in server side of the things. Here are a few techniques I have found useful while debugging an issue and may be useful for others as well.

Calm Mind

We might find ourselves in a firefighting situation during product delivery.
Ironically, debugging requires a calm and patient mind, which leads to clarity of thoughts. Meditative mind and peaceful surrounding is a bonus.

Question Everything

When an issue is reported, it comes with a few observations and assumptions. Question everything — don’t take anything at face value. This is a very important step in debugging. If we accept an assumption as fact without proper thought, it can lead us in a completely wrong direction. This can result in a lot of wasted time and energy.

Corner the Issue

Usually, we have doubts about multiple components when an issue arises. Sometimes, as a first step, rather than trying to find the root cause, it helps to eliminate components that are unlikely to be responsible. This helps us focus our energy on the right areas of the application.

Analyze the Logs with a Detective Mindset

Analyzing logs is much like being a detective at a crime scene. You need to wear the hat of Sherlock Holmes to be a good debugger.
Logs are like evidence left by a culprit at a crime scene. Logs tell the story of user actions and application behavior. Watch out for unusual turns in the story. Sometimes, unusual events occur well before the actual problem. So, don’t ignore even a single line. For this, we can rely on fast text search editors like Notepad++.

Logs with useful information are real gold when facing production issues. Therefore, developers should put extra effort into writing useful logs.

Debug in the Mind

For many scenarios, we do not need to run the code to see whether it works or fails. Sometimes, it helps to think aloud or, better yet, write things down. This saves a lot of time and removes false assumptions. For this, we do not need to sit in front of a screen; it can be done while taking a walk in the park as well.

Take Breaks

Many times, taking breaks from continuous debugging and resuming the next morning has given me fresh insights into the issue. Although it sounds counterintuitive, and it’s difficult to step away from a pressing issue, sometimes it is necessary.

I am sure fellow developers will have their own insights into Software debugging. Do let me know your insights and experiences on debugging!

0
Subscribe to my newsletter

Read articles from Omkar Shetkar directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Omkar Shetkar
Omkar Shetkar

Software developer by profession. Currently living in Bangalore, India. My interests include to get updated with the latest technologies and trends. I usually write about Java, Cloud technologies, Productivity tools, and Books. I don't have any affection for any political ideology. Furthermore, I believe in a lifestyle which comprises Yoga, Meditation, Work, Good Food, and service to society in whatsoever possible.