How to Read Source Code
I recently read an article - How To Read Source Code. I deeply resonated with it, so I’m marking down my thoughts here.
Purpose of Reading Source Code
- Solving needs, for example, I look at inshellisense to solve auto-completion development needs, check click to component to solve JB IDE support issues. In short, you can’t talk about secondary development based on source code without reading it.
- Besides solving needs, you can also understand these experts’ design thinking, even their coding styles.
Should You Read Source Code?
Having mentioned the benefits above, naturally you should. Free code, free learning opportunities - not reading would be a waste.
Ways to Read Source Code
I personally think there’s no fixed way to read code. For example, understanding parts of code through unit tests is fine, running the project is also fine, etc. There are many methods. Of course, the best way is if you can submit a PR, because the prerequisite for submitting a PR is that you probably understand how the entire project runs.
For myself, I’ve previously contributed PRs to several open source projects. For example:
No Time to Read Source Code?
I used to make this cognitive error too, not reading source code for many years. I personally think if a coder doesn’t have time to read source code, that means they’re quite unsuccessful, probably just busy with meaningless work.
Final Thoughts
In short, try reading more source code - it’s all benefits. Let’s encourage each other.