You face a problem with your code. Maybe something is bugging you about the design approach. Or maybe you’re just plain stuck. What can you do to break through a mental block?
During one job interview, I remember asking how the candidate approached problem solving. That candidate’s answer has stuck with me over the years:
I stop the car. I get out of the car and walk around it. I get back in the car.
This really is “one weird trick,” and surprisingly effective. It acknowledges that repeating the same thing without change will probably yield the same result. So, stop.
Reminder: ‘Going for a walk’ is a pro debugging technique.
— Kris Jenkins (@krisajenkins) November 16, 2017
You see, once I’ve decided on a tentative approach, my mind digs in. It really wants to push through until that approach yields a solution. But if the approach doesn’t work, my mind keeps digging deeper — digging and digging until ruts form.
I need ways to dislodge my thinking out of that rut. I need to get access to different points of view. There’s one meta-trick, but here are 5 different ways to apply it:
1. Mental block? Use the Pomodoro technique
One thing I practice is the Pomodoro technique:
- I set a timer for 25 minutes.
- While the timer is running, I try to concentrate on a single task.
- When the timer finishes, I physically step away from the computer for 5 minutes.
I emphasize the act of physically stepping away, because it seems to do something for me.
…Get a timer that actually interrupts your work
While you can use any timer, I discovered a problem:
- Timer displays a notification.
- Notification auto-dismisses.
- I am free to ignore it. Or I may have stepped away from my computer while the notification was shown.
- I continue to work without a break.
- This continues throughout the day. I come home exhausted. My evening is spent recovering.
A notification that dismisses itself wasn’t enough to actually interrupt my work. I need a stronger reminder to keep me from having lousy evenings.
Thankfully, my friend Radek Pietruszewski has written an app that does exactly what I need! Check out Tadam on the Mac App Store.
2. Mental block? Work on something different
Stop working on the current problem. Pick a different task. Occupy your mind with something else for a while.
3. Mental block? Sleep on it
Put down the problem for the day. Without a computer, briefly consider the problem before going to bed. Then go to sleep. Freed of the need to concentrate, your dreaming mind may explore other possibilities.
(This is actually the approach I take for some blog posts. I sketch out some ideas, then go to bed.)
4. Mental block? Try it in a different language
I already TDD’d an Objective-C version of a class that authenticates calls to the Marvel API. There were things about it that bothered me, but not enough to go back and revisit. The important thing at the time was to make progress — any progress.
But my Swift version came out rather different. I still TDD’d the simplest things, starting with simple methods. And from my earlier effort, I was interested in using closures for injecting different algorithms.
Maybe because Swift closures are more uniform and less wordy than Objective-C blocks, something different emerged. Programming languages have different strengths and expressiveness, so trying an implementation in a different language may open your mind to alternate approaches.
5. Mental block? Grab a buddy
No matter how much you rest your mind, it’s still your own mind. The quickest way to get a different point of view is to get input from a different person.
This is the strength of Pair Programming. Two people are much less likely to hit a mental block than one person. And when you do, switch roles. That is, the driver becomes the navigator, and the navigator becomes the driver.
What if two people, pairing together, hit a roadblock? Add another navigator. This moves us closer to Mob Programming.
When we’re stuck on problems, we need ways to see different possibilities, different points of view. This can come from doing some kind of “mind reset,” which is often physical. It can also come from getting more people on the problem.
Whatever you do, stop the car.
What are your favorite ways to jar your mind loose to see alternate approaches to a problem? What techniques and tools work for you? Please share in the comments below!