DEV Community

Tran Thi My Linh
Tran Thi My Linh

Posted on

Confusion while coding

This is the first post in my book review series.

The reason I've decided to write this serie is because I struggled a lot with reading and understanding code written by other developers, and I still do. It got even harder when I started focusing more on backend programming instead of frontend. Backend coding is quite different, and it requires a different way of reading.

I always wondered if other developers have a natural ability to read code like it's a regular language. For me, it wasn't that easy. I realised that it's a skill that can be acquired, so I looked for some guidance.

My current company provides free access to O'Reilly, an awesome platform with tons of engineering books. I found a book there called The Programmer's Brain by Felienne Hermans, and it caught my attention.

In the first chapter, the book directly addresses the challenge I face in understanding code: "Decoding your confusion while coding."

Confusion is what I've been feeling all along. Often, I find myself perplexed when deciphering patterns, classes, methods, and variables. Occasionally, I even forget the purpose of a method or variable as I navigate through the codebase.

According to the author, before we can truly grasp code, we must understand the reasons behind our confusion.

To put it simply, there are three types of confusion when reading code:

  • Lack of knowledge: Imagine reading code in a language you're not very familiar with. Every new syntax becomes a roadblock in your code-reading flow.

  • Lack of information: Imagine reviewing code in a pull request on GitHub. You come across a method that requires you to navigate to another method to understand what it does. But you can't do it directly in the GitHub interface without the help of your editor. You don't have enough information.

  • Lack of processing power: Think of a function where you understand every syntax and variable. But it involves calculations that are too complex to process mentally without writing down each step of the program.

These confusions stem from issues in different aspects of memory. Lack of knowledge relates to long-term memory (LTM), while lack of information relates to short-term memory (STM). On the other hand, lack of processing power refers to the working memory.

I find the metaphor used by the author quite insightful. It's like comparing LTM to the hard drive of a computer, STM to the RAM or cache, and the working memory to the brain's processor.

Information filter flow

So, whenever we read code, our brain utilizes various areas of memory. I guess to enhance our ability to read code, we need to train ourselves to better utilize these cognitive processes.

Top comments (0)