Often while coding I experience mental blocks. I feel stuck. This feeling makes me aware of a potential skill to be developed. Probably the most important skill. I ask myself, how do you break such mental blocks (feeling of being stuck)??
First step is to recognise that you are feeling blocked. This is not always obvious. This feeling can manifest in form of lethargy, procrastination, moodiness or other excuses. This “being stuck” happens to me when I have no clue on how to solve a problem. The problem seems to be impossible to solve. I don’t know where to begin. I’ve observed that when I’m hooked on a problem, it’s a very different feeling altogether. Blissful!! My observation is, you feel challenged, if you know fair amount about solving the problem, you believe you can solve the problem BUT you are gonna have to figure out a tricky part of the puzzle. You are almost there, a little more and you will be home. That feeling. It’s an exciting feeling. But the key is, you believe you can solve the problem and you tell your self continuously….Almost there buddy, a little more, almost there. Exciting!!!
Being stuck is very different from this feeling of being challenged. You almost know next to nothing about the problem. Often I don’t understand the problem or even if I do, I don’t know where to start. Hence the procrastination.
The first obvious step for me is, know your unknowns. You got to have a list of QUESTIONS you can’t answer. This needs fair amount of introspection.
- What do I need to know to solve this problem?
- What’s the expected output in different situations?
- What resources do I need to solve this problem?
I take pen and start scribbling. It gives me a feeling of moving forward. Typing doesn’t work for me. These questions help me figure out that list of questions I need to answer. These questions are tools.
Next, mental process is, divide and conquer. You have to divide your problem in smaller problems. You divide until you get problems that you can solve. It’s a mental recursion. You keep dividing the problem. Use pen and paper. That really helps. Now when you do this, there will be one more thing which will happen in parallel. You will start gathering new information. I don’t try to understand everything at once, don’t stress about it. Just read it over and over. Your brain magically process it more and more in each iteration.
Let’s say I am debugging huge code written by somebody else. I read the source code just to get a feel of it. I don’t try to understand it. Don’t dig into the details. I look at coding patterns. It’s almost like building a mental index of what is written in which file. I just trust my brain to remember things. I do not try to remember. Just go over it, again and again. The logic behind this process is, I believe the brain just knows how to put those small clues together into a story. This is my process of finding the unknowns. Depending on the complexity of the problem, I always budget out some time for this R&D. It helps a lot. Helps me have a epiphany when I really need it.
Interestingly , some mental blocks are caused by desire to solve a problem in the best way in very first attempt. These blocks are subtle and end up wasting a lot of my time. Thus I prefer following a simple rule from Adi Osmani:
First do it, then do it the right way, then do it better.
Trying to get it perfect in the very first attempt can delay small successes which leads to either lack of motivation or frustration.
To summarise, my mental process to solve “feeling of being stuck” is
- Make a list of unknowns
- Gather information and validate it. Let your mind show you the full picture.
- Play with the system.
- Repeat. Iterate over and over to perfection.