editione1.0.1
Updated August 7, 2023Codebases are complex, plain and simple. A codebaseโs complexity can be roughly estimated as proportional to the number of engineers who have contributed to the codebase multiplied by its age. As more developers contribute to a codebase over time, the complexity continues to increase.
Itโs almost impossible to understand every line of a codebase, especially if you didnโt write it yourself. In fact, even a solo developer who has written every single line of a codebase will forget the details and context of parts of the system over time. They may come back to a file they wrote months ago and struggle to remember how it works.
Setting the right expectations now will help reduce your frustrations in the future. Itโs okay if you donโt understand how every line of code in a program works.
As developers, itโs our job to form a mental model of how a program works, and how the pieces fit together to form a complete system. You have a limited capacity in your brain to hold this mental model, and eventually, youโll hit a saturation point where youโre not able to hold the entire mental model in your head at once. As you learn new parts of the system, you may forget other parts you havenโt visited in a while. Itโs natural and common among all software engineers.
Depending on the size of the codebase, it may even take years to feel like you know your way around it. It certainly doesnโt help that the codebase is constantly changing as new features are added, bugs are fixed, tests are written, algorithms are optimized, and engineers come and go. Part of the system you understood months ago might have been refactored since then and now works completely differently. Youโll always be chasing a moving target, so donโt beat yourself up if you donโt understand every corner of a codebase.
The best thing to do is to accept that you wonโt have a deep understanding of every single part of a codebase, and thatโs okay. As long as you work hard to form a mental model about the parts youโre responsible for, things will start to make more sense. It wonโt happen all at once, but given enough time, the picture will become clearer and clearer. The trick is to be patient and get comfortable with reading unfamiliar code, because youโll be doing it for your entire career.
Learn to Read the Source, Luke (blog.codinghorror.com)
How to Read Code (Eight Things to Remember) (spin.atomicobject.com)
How to read a code (iamjonas.me)
Reading Code is a Skill (trishagee.com)