Most of us don’t like debugging: it bothers from current tasks and
disappointing, because hints that we’ve done our work in bad faith.
But in real life software without bugs is not possible. If so, let’s do
something with it!
And at some point I realized that debugging actually is not so bad. More than
that it can help you a lot in future.
But to get it you should follow some rules.
- Never do monkey debugging firstly. Usually it means using logs or debugger to
get runtime values at certain point of execution.
- Never do debugging in autopilot mode.
Humans are lazy. They try to find the shortest way to solve the problem. And
logging is it. We don’t mind, just mechanically searching for a place in code,
step by step. It can take 3 minutes or 3 hours.
Then found. Fixed.
We didn’t mind and analyze the real issue and as a result don’t remember the
code structure. And when it happens again we have to start from the beginning.
And this is a real trap. Errors are insidious ones and can turn out to be a very
deep hole. At the end hot fixes lead to more and more bugs.
Spending just several minutes trying to investigate the issue in our head we:
- refresh our knowledges about architecture
- get extended and advanced vision of the problem
- can do proper conclusions
- prevent other such problems (in future or already existed)
There is even an exercise for memory training: before going to sleep remember
everything that happened today in reverse order. Debugging is the same, just
remember all things related to the issue. Sometimes it’s hard or even not
possible, but attempt definitely have to be.
I have a small list of steps, that helps me in debugging:
- There is no magic here. Really. Yes, I know that you are sure, that you wrote
everything correctly. But there is no magic. It’s computer. And not quantum one.
- You look into the wrong file/database/repository
- Where were the last changes?
- Extend the vision. Things are got by many ways.
- Read more precisely suspicious places
- Go through the code, executing it line by line
- Go for coffee
- Have a talk with someone about pokemons
- Try again 3-6
- If nothing helps, ok, use the debugger or logs.
The best thing in debugging is a possibility to have a guess about a real
It’s like a riddle. Everyone likes riddles, it needs just to feel the bug as a
puzzle. We have initial conditions which lead to the incorrect behavior. That’s
your riddle description. Try to write down at least several possible reasons of
Solving problem in this way turns routine into the game and success brings much
more pleasure than solving by monkey debugging, after which you probably would
think: “Hell, I could have a guess about it, actually”
Take care and have no bugs!