How to Debug Code 10 Times Faster?

I use the binary search method

Dmitry | Relationships Guide
Technology Hits
2 min readNov 23, 2023

--

My image, generated by DALL-E-3 AI

What’s the point?

Binary search, as an algorithm, works similarly to how you search for a house on a certain street.

If you are dropped off in the center and you know which house number is on the left and which is on the right, then you will easily decide where to go to find the house you need, cutting off half of the possible options in the process.

🔹 For example, if you are on a street where house numbers start from 0 to 100, and you are dropped off at house number 50, and you are looking for number 78, then you definitely won’t go in the direction where you saw house 49.

Just imagine now that you can jump like Superman.

And each time you jump exactly half the distance of the segment you are going to.
Thus, after each jump, you filter out 50% of the options available at that moment.

How to apply this method in work?

  • To be able to make a 50% jump, you need to know the starting and ending points.
    For this, it is necessary to understand how the program is executed, through which stages it passes.
  • Rendering a web-application is conceptually a fairly straightforward, chronologically ordered process.
  • Using mocks (hello TDD), we can isolate entire layers of the application, which will make you a real debugging ninja.

What is my most common case?

When a new bug appears related to legacy.
Obscure and potentially long to resolve.

🔸 The first point in my head is to clarify the priority of the bug and understand its cause.

For this, I go to Git.

And I go back six months. If the bug still exists there — we decide whether we need to fix it right now.

Many such bugs have generally already been filtered out at this stage.

If we still decide to fix it. I try to understand which change gave birth to this bug.

Returning to git already three months ago.

I check if the bug exists at this point. And so on, until I find the problematic commit.

On average, it takes me 3–6 jumps to succeed.

Thank you for reading! 🙏

If you liked the article, you can follow me here:
X (former Twitter) | LinkedIn

--

--

Dmitry | Relationships Guide
Technology Hits

Relationships Coach ❤️‍🩹 Transform your relationships into a fulfilling connection 🌿 A data-driven, scientific approach forged in 15-year marriage 🧬