Tiny Tip – When You’re Stuck Coding, Write a Letter You’ll Never Send

When I’m programming, I often run into problems I can’t solve. I’ve gotten pretty good at reading the documentation (at Bart’s insistence), and I read lots of forum discussions on sites like Stack Overflow where people help each other with their code, but it’s pretty common that I still can’t figure out how to fix my code.

I often engage Dorothy in a text chat, which sometimes turns into a Skype chat with screen sharing. One of the most annoying things about Dorothy helping me is that she always asks me what I’m trying to DO. It’s annoying because it’s the right question. I’ll be down in the weeds saying, “I can’t push into this array” but she wants to know why I want to push into the array and what I hope to accomplish when I do.

Sometimes I write an email to Dorothy or to Bart where I describe the problem on which I’m stuck. What I find really often is that as I try to articulate the problem I’m having, I have to keep mutating my sentences as I discover logic problems or syntax problems.

Recently I was stuck on a rather gnarly coding problem and I came up with an absolutely fabulous solution.

I didn’t write to Dorothy and I didn’t write to Bart. I wrote a letter with no intention of sending it to anyone at all. My theory was that I might be able to solve my own problem if I simply pretended I was going to send the letter.

I started by writing out what wasn’t working. As I tried to explain the problem, I found two entire functions that I had written and yet never used to do anything. As I tried to explain why they were there in my fake letter, I was able to verify that they didn’t need to be there at all. My code just got simpler.

I’m not surprised to find extra code lying around. I program in fits and starts. When I start coding, it is all-consuming. Hours and hours can go by in the blink of an eye, which often turns into days where I get nothing else done. After three days, I realize I have to write for the podcast so I have to stop, and I may not get back to what I was doing for weeks or sometimes even months.

I wish I could figure out a way to set aside maybe 4-8 hours per week to program so I would make slow but steady progress, but I can’t figure out a way to do that. If I wrote function during one of those fits and starts, I may not even remember doing it weeks later when I come back to it.

Once I had documented where I was stuck and eliminated unnecessary code, I channeled my inner Dorothy and asked myself what was I trying to do? As much as I hate to give Dorothy a pat on the back, that question was exactly what I needed to ask to figure out where I’d gone wrong.

After a day or two of trying to write a coherent description of my problem that I never intended to send to anyone, I figured out what I was actually trying to do, I eliminated unnecessary code, and I wrote some tight code that actually accomplished my goal.

Perhaps this is a technique that seasoned programmers already know all about, but I wanted to share because it was a huge help to me to write a letter I never intended to send.

Leave a Reply

Your email address will not be published.

Scroll to top