Skip to content

3 Things to Do When You Can't Figure Out the Code

twitter logo ・1 min read  

Take a break

Step away for a few minutes and come back to it.

Challenge your assumptions

You may be going down the wrong path because you are assuming a method or class works in a particular way when it actually doesn't.

Ask a colleague for help

Don't know who to ask? Check the Git history of the file to see who's worked on it recently.

twitter logo DISCUSS (9)
markdown guide

Start writing an email to an imaginary person, explaining the issue and what you've done.


If you really want to be fun, put a Teddy Bear or other stuffed animal on your desk and explain to your friend the problem you're having. AKA "Teddy Pair Programming"

Either of these two things will probably have you realizing the solution during the middle of your explaining.


110% agreed. Another alternative is to start writing a question on StackOverflow (or equivalent). I tried it a couple times and figured out the solution by myself while describing the problem. And if it does work you can just send the question for real !


I like the first one best "Take a break". The brain is mysterious thing. It's marvelous how it can come back fresh after a break, then you can spot obvious problems (it may just be eye-fatigue, but I really think it's the brain)


It has happened many times, that when I did not know the answer to a problem I was having, I would direct my attention on StackOverflow in search for help. In there, quality posts are required, if you do not want your question shut down, so I would think carefully my query, and start writing it down on the input field. And as this question starts taking form... suddenly I realize there are things that I have not tried. Things that could very easily be the cause of my problem.

This experience makes me realize every time, how much can learn by formulating question.

  1. Explain each line in comments
  2. Use breakpoints in debugger to understand flow and values
  3. Explain to colleague what you know, then ask... Often before you get to the ask part you might have figured it yourself.
  4. If still unclear, go for a walk, run, go boxing, take a nap then come back. Sometimes that aha moment comes when you least expect it.

I agree with point 1! Sleeping on it usually helps me. Sometimes, if it isn't mission critical, coming back to it after a few days.

Thanks for sharing Amir!


Writing things down or drawing diagrams on paper sometimes helps me figure things out.


I agree. The human brain is kinda like a computer too, if it's not functioning properly REBOOT

Classic DEV Post from Mar 2

What effect is the Coronavirus having on your work life and personal life?

Do you go into an office on work days? Is your company taking precautions? Are you taking personal pr...

Amir Boroumand profile image
Software Engineer specializing in backend Java development of web applications

Hey there reader...

Do you prefer sans serif over serif?

You can change your font preferences in the "misc" section of your settings. ❤️