Debugging is perhaps the skill that I find programmers have the hardest time exercising. It is also the most difficult to teach. Debugging, to me, is both a scientific discipline and an art. It often requires you to reach beyond analytical thinking to rely upon your own intuition in order to solve a problem.
Many devlopers use empirical approaches, systematically addressing each possible problem branch. If A, then B. If B, then C. If C, then D. This analytical approach works well and is easy to teach. The problem I find, though, is that many focus on identifying solutions before fully grokking the problem. This leads to approaches that begin with D and work their way backwards to A, resulting in wild goose chases and wasted time.
That's not usually how I approach debugging. For me, an approach based on intuition is key. But intuition is a tricky thing, isn't it? After all, having a gut feeling about something seems mystical and a little paranormal. I don't think it is, though. Wiktionary defines intuition as a€oimmediate cognition without the use of conscious rational processes.a€¯ Here's how I think it works. Your brain is constantly making computations, much like a Frank Herbert mentat. It has the data it needs, makes the calculation faster than you can blink your eyes, draws conclusions, and gives you the response in the form of a short-but-sweet gut instinct. That's immediate cognition, and you weren't conscious of any rational process being used.
This constant computation is something everyone does, but in Western civilization, we have suppressed it in favor of the rational approach. We can learn to develop it, listen to it, and, along with analytical thinking, make it a part of our standard thought processes. Here are some ways to make intuition a part of your debugging habits.
As developers, when we encounter problems that require intense debugging, we're often in a rush, especially if it's something that affects a production environment. This rushed mindset creates the worst possible conditions for allowing you to effectively target the problem and identify a solution. When rushed, you don't think clearly about where to begin, much less how to solve the problem. To think clearly, you must slow down.
When you find yourself rushing to fix a bug, it's best to stop what you're doing, close your eyes, take a deep breath, and let it out slowly. I know it sounds hokey, but this isn't transcendental meditation. It's perspective. It's focus. When you take the time to slow down and focus, you can tap into your intuition, using it to discover where to begin and how to solve the problem.
In his biography of Steve Jobs, Walter Isaacson quotes Jobs as saying this about intuition and slowing down your mind:
a€oIf you just sit and observe, you will see how restless your mind is. If you try to calm it, it only makes it worse, but over time it does calm, and when it does, there's room to hear more subtle thingsa€‰-a€‰that's when your intution starts to blossom and you start to see things more clearly and be in the present more. Your mind just slows down, and you see a tremendous expanse in the moment. You see so much more than you could see before. It's a discipline; you have to practice it.a€¯
Stop saying a€oI don't knowa€¯
As developers, we like to focus on constraints. Software construction is all about finding the constraints of a problem domain and programming a solution to fit within those constraints. It's no wonder our lives and jobs revolve around constraints, and we like it that way. But constraints can hold us back and squelch our intuition. When we assume we don't know the answer to a problem, we impose a constraint upon ourselves that makes it more difficult for us to find the answer.
In her book, Grow Your Intuition: 6 Simple Steps, Suzan Bond says that we shut off our intuition when we answer questions with, a€oI don't know.a€¯ She goes on to say, a€oWhen you stop using this phrase as much, you will open up your intuition. You'll be able to see more possibilities, rather than limitations.a€¯
It's not wrong to admit lack of knowledge in an area, and I'm not advocating that you make up answers, but the truth is that you may already know the solution. Your brain already has the data it needs. Slow down. Take a breath. Ponder on it. Let your intuition speak to you. If you have trouble finding a solution, ask yourself what may be blocking you from seeing it. Don't accep
Truncated by Planet PHP, read more at the original (another 6188 bytes)