A letter to the lonely developer
Tags: softwaredevelopment, bugfixing, softwareengineering, debugging
Published: 2020-09-03 06:05:31

---
title: A letter to the lonely developer
published: true
date: 2020-09-03 05:46:04 UTC
tags: softwaredevelopment,bugfixing,softwareengineering,debugging
canonical_url: https://medium.com/@dvirsegal/a-letter-to-the-lonely-developer-bd0ac22ba714
---

![](https://cdn-images-1.medium.com/max/1024/0*YHIzbxxpBG0JIXi4)<figcaption>Photo by <a href="https://unsplash.com/@glenncarstenspeters?utm_source=medium&amp;utm_medium=referral">Glenn Carstens-Peters</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption>

#### Me against a bug, reminding myself how to solve any defect

Dear developer,

Don’t give up, keep up with your efforts to find other ways to understand the bug’s root cause. I know it can be frustrating. The agonies with the process can be ruff. But, you’ve got it, you solved many in the past, and you will solve this one too. It is part of your job.

![](https://cdn-images-1.medium.com/max/614/1*ldXebu55vPs_GfTMLjkWFA.png)<figcaption>5 stages of debugging</figcaption>

#### Investigate the crime scene 🕵️

Embrace all your experience, the collective knowledge you gained with your past ventures. Rely on **previous bug records** that you assume related to the defect’s scenario, you might find some hidden gems that will help you think of a way to cope with it. **Check any logs** the application writes, search for any abnormal behavior (such as errors, exceptions, etc..). Collect that interrelated items into your brain (or better write them down).

**Use version control** , read the history of the files you suspect the issue resides within. Rollback through versions’ history, up to a point it is no longer reproduced. Thus, helping you to understand the specific version in which the issue was first observed.

**Identify main suspects** (controllers, buttons, interactions, etc.) that participate in the scenario, have a strong understanding of the steps that produce the bug, try to identify its frequency, whether an always reproduced anomaly and in which conditions. **Get familiar with what is the expected behavior**.

Wisely spread breakpoint using a good debugger (_invaluable_) and do line breaks steps. **Navigate through stack trace** on the application’s main flow (for example input and output around the code’s area), use dedicated IDE **extensions** that assist you while debugging (such as [OzCode](https://dev.to/dejavo/ozcode-a-new-way-to-debug-your-code-l6n)).

No clue what the problem is? **Ask someone** ; it might be a coworker, a friend, or an online community. Show them the information pieces you’ve collected. Generally Explain what the program does, what it should be doing in this particular instance, and what it’s actually doing.

Share code snippets of what you’ve narrowed down using the IDE while asking for guidance: “I identified the issue is created by the following code, it’s setting the value to X when it should be Y, but I can’t see why that’s happening”. There is nothing like **a fresh pair of eyes to solve the riddle**.

Furthermore, **books** (for [#1](https://www.amazon.com/dp/B00PDDKQV2/ref=cm_sw_r_tw_dp_x_1h2sFb7DTZV1V) or [#2](https://www.amazon.com/Effective-Debugging-Specific-Software-Development-ebook/dp/B01HMR617O)) on advanced debugging skills can be your friend too. Reading will help you think of creative solutions. I bet you’ll find some tricks out of your sleeve afterward.

**Repeat** the above until you’ve got that **eureka ** moment.

#### Now that you’ve identified the root cause, what else? 🙄

![](https://cdn-images-1.medium.com/max/493/1*NtY-e53ZzDoHDbx9vKUATw.png)<figcaption>Found it!</figcaption>

Try creative ways to solve it. If you find yourself struggling, go to the framework API documentation (such as [Microsoft docs](https://docs.microsoft.com/en-us/dotnet/api/)) or read trough your project **design documents** , both might reveal the hidden parts.

**Search for similar solutions** using your favorite search engine (e.g., [DuckDuckGo](https://duckduckgo.com/)), filter relevant results — you might find blogs, books, and tons of information on related subjects. It is not a shame to read answers in [StackOverflow](https://stackoverflow.com/), so use it wisely.

Apply various techniques, such as registering to main flow events, adding helpful log printouts, reading the framework’s source code (in case [available](https://referencesource.microsoft.com/)). Consider if **refactoring** is needed to reduce coupling, don’t just fix a bug, fix the entire class, so you’ll never be able to create similar bugs again.

![](https://cdn-images-1.medium.com/max/492/1*EaOXnS72a7xPEPUKt7nGpA.png)<figcaption>overkill — <a href="https://i.kym-cdn.com/photos/images/facebook/000/590/940/e4d.jpg">src</a></figcaption>

One last thing, it’s a kind of an overkill, but if all odds are against you, use a reflector (it depends on the language), which enables debugging without source code (unless not allowed — [obfuscation](https://en.wikipedia.org/wiki/Obfuscated_code)) to pinpoint the issue. I highly recommend using **dnSpy** , which I previously [blogged](https://medium.com/@dvirsegal/when-in-doubt-reverse-engineer-it-4ad4c4a707e2) about.

#### Managed to fix it? 🧩

![](https://cdn-images-1.medium.com/max/401/1*uV8k54K5-An8fsSsufGmlQ.gif)<figcaption>Done — <a href="https://64.media.tumblr.com/3fee2efc087f9ea6ca482c2705797571/tumblr_p668aozjm41qmob6ro1_500.gifv">src</a></figcaption>

The battle hasn’t finished —  **add unit tests** to prevent a “make a fix, cause a problem elsewhere” situation. Update the **design document** if needed, run automatic or manual **sanity tests** to verify the fix. Add code **comments** to explain the context (the “why”) of the fix (more on [that](https://medium.com/dev-genius/code-comments-are-your-code-autobiography-7202c45b5e37)).

Question your methods, you may be able to **learn and get better** , so ask yourself:

- How could I have avoided this waste of time?
- What did I overlook in the first place, and why?
- What unvalidated and/or wrong assumptions did I rely on?

It will improve your abilities. Furthermore, sharpening your **gut instinct**. Eventually, over time you learn to automatically notice all those minor signals that are too easily overlooked, leading you quickly to the right answer. In the end, it’s all about **deliberate practice**.

**Share what you’ve learned** during the whole process, prepare some slides, and have a post-mortem session with your colleagues, so others will benefit from your experience too.

Lastly, don’t forget [Alan J. Perlis](https://en.wikipedia.org/wiki/Alan_Perlis) words:

> There are two ways to write error-free programs; only the third one works.

Sincerely (until next time),   
Your future-self