Solving Programming Roadblocks
Imagine. You've been staring at a page of code for the last hour, but you can't see how it could produce the results you're seeing. We've all been there, right? You analyze every line, you test every edge case you can think of, you see no logical flaws, and yet it fails for some combinations of input (and only on Fridays!), causing a big ugly line across the middle of your otherwise beautifully rendered CGI landscape... or worse, the rescue drone crashes into the side of the building instead of landing gently on its roof.
What do you do when you have a problem you just can't solve?
First, notice how the question uses the word "you" three times. Maybe it's true you can't solve the problem—at least not by yourself. As programmers, we sometimes forget we don't need to solve every problem on our own. And this is not to say pair programming or a team debugging session is the answer; it might just mean explaining the problem to a friend or family member — it's probably even better if they aren't a programmer because sometimes describing a problem in non-technical terms can lead to a breakthrough. It's incredible how many times we've gained critical insights into a problem by describing it to my dog. Mostly she stared at me curiously and then was disappointed when I ran back to my computer without giving her a treat.
Sometimes, paradoxically, the way to solve a problem is to stop trying. Instead of staring at the same code for another three hours, just walk away from it. Go get some sunlight (this requires going outside in case you've forgotten where the sun is), listen to your favorite heavy metal album, or walk to your local cafe and get an organic oat milk latte. There have been many times we couldn't see the solution right in front of me, but when we took a break it became obvious. The human brain works in mysterious ways... a programmer's brain even more so.
领英推荐
Lastly, maybe you're trying to solve the wrong problem. Redefine the problem. Or zoom out from it and solve the problem behind the problem. Maybe you're trying to build a bridge across the wrong part of the river. Maybe you should take a boat instead!
Ironically, figuring out a closing paragraph for this article turned out to be a problem we just couldn't solve. So, applying the principles in the article, (1) We put it aside for a couple days and came back to it, (2) We explained the problem to my dog (her suggestion involved a tennis ball, which wasn't very helpful), and (3) We thought of a different approach.
For now, this is the end of "part 1." So, until next time, we wish you success in all your problem solving!