Improve your development/investigation skills by debugging

Sampat Badhe
4 min readJan 15, 2018

--

Debugging is a craft in which we could improve, but as a tedious factory job that needs to do when you’re a developer. And nobody wants to do dull work, so here we will be looking for ways to improve our debugging skills so we could be more efficient at it. Nowadays debugging became an art which takes ongoing efforts to master. But can be really fun when we get better at it.

The mindset and attitude to debugging is perhaps the most important part because it determines how effectively you’ll fix the error, and what you’ll learn from it — if anything.

& the right mindset is: They’re errors not bugs

Before you continue it’s important to have the right mindset. Remember: every error is an opportunity to learn, almost always about yourself (because only beginners blame the computer). And yes, they’re errors, not bugs! As Dijkstra stated: the term bugs support the idea that something sneaked in our code while we weren’t looking, instead of being there by our own creation.

The main culprit for these errors are ASSUMPTIONS:

Assumptions are wonderful, these quick conclusions are what makes you a real expert, but sometimes they are just plain wrong. How many times did you spend hours and hours staring at lines of code and saying: “This should work!” Blinded by your assumptions, unable to see the obvious flaw right under your nose. When you finally found the error, you decide to quit your job, because of how stupid you were not seeing your mistake right away.

There are 4 states of knowledge.

  • We don’t know something
  • We do know something
  • We know there is something we don’t know
  • We don’t know what it is we don’t know

So Don’t Assume Anything…

It’s often tempting to just say “oh, I know what this bit of code is doing, it’s fine”. Don’t do that. Test every assumption and step through everything carefully.

Assume as much as you can but at the same time don’t forget to prove your assumption.

Here’s some list of Debugging “Rules” for programming:

Be strong and disciplined. Debugging is a process, said one developer, not a series of random events. Don’t randomly tweak knobs; follow the code’s execution process.

Be Focused. Debugging is easiest when you can hold the whole system in your head. Don’t make the mistake of focusing on only one part of an application. Pay attention to the interrelationships between modules. Read the code at multiple levels of abstraction, advised one programmer.

Fail Early Learn Early. Learn to fix bugs as early in the development process as you can. That might mean something formalized, such as test-driven development.

Do cross-peer debugging. To improve your skills, debug other people’s code rather than your own. It will be easier to see the faults in the other person’s assumptions than it is to see your own.

Follow Baby Steps: Run your code every time you make a significant change. Don’t randomly tweak code; follow the code’s execution process and validate your assumptions. Ask yourself the question: “If I change this part of the code will it result in the expected behavior?” Yes, continue with the next change.

Follow Rubber ducking: Have you had the experience when explaining a programming problem to someone else, even to someone who doesn’t know anything about coding, and in a sudden realization, finding a solution?

Identify Code Smell: it refers to code that needs to be fixed because it has grown too complicated, or too coupled, or for any other reason that causes it to be difficult to maintain.

Take a small break when you feel overwhelmed: Its natural to feel overwhelmed/stress while debugging. Whenever you feel overwhelmed/stressed, take a small break and Take your mind off it.
Eg: Power nap of less than 20 minutes, Listen to the right kind of music….etc..

Ask for the help: Don’t shy to take the help from someone at the right time with the right set of questions.

As Leaders mature, they start building mental blocks based on their past experiences. They start taking a position / make statements based on these blocks but do not realize that the environment is changing and those blocks are no longer valid. This is a human tendency which works two-ways it helps us to grow initially and not repeat mistakes and is also the reason for our short-sightedness as we mature. — Tushar Vagal (CIO — L&T Realty at Larsen & Toubro)

--

--