Reading code — a must-have skill

Leo_on_west_coast
2 min readJan 14, 2022

--

There are plenty of materials teaching programming languages, debugging, libraries/frameworks, design pattern, etc. But I didn’t read anything that teaches people how to read code. Reading code is a really important skill that every software engineer must master.

Working in the industry for almost a decade, I realize that 1) we always do our work in an existing codebase, it is rare to start something from scratch; 2) wiki/documentation is always out of date, the most accurate information is in code. So reading code is the best way to learn; however, I found many of my coworkers are not good at reading code by themselves, they’d rather rely on second-hand information. Admittedly, asking other people is the most efficient way to gather information, but it is not acceptable that you need to ask other people for everything, a lot of the answers are in code. I still remember one of my coworker in my early career. He is so good at navigating through large codebase and understand how systems work, even if the system is not owned by him. By doing so, it is natural for him to expand the scope, because only him understands how end to end works (other people only understand their own component).

So, why is it hard to read code?

Many engineers don’t like to read code because it is not easy.

  1. We can blame the code quality for sure. Even if in Google, which is considered having the best quality of code in industry, lots of code is hard to read. Why? Because we are entering a mediocre age. Lots of the code is about business logic and written by mediocre engineers. Although the complain about bad code quality is always true, we have to live with it.
  2. Code is a translation of ideas. The essence of reading code is to understand the ideas. It is hard to describe an idea clearly using English, not to mention using code. We need to reverse engineering the translation process: code -> description of ideas -> ideas themselves. This process is not easy.
  3. It is not easy to build a structure when reading code. When reading books, we always start from Chapter 1. The author designs the book linearly so that we can follow the logic chapter by chapter. Reading code is sometimes like going through rabbit holes: a function refers to another function referring to another function.

In the next post, I will share how I read a new codebase. Stay tuned.

https://medium.com/@hlxmtv/read-code-a-must-have-skills-2-b7b9a1c1a0ab

--

--