editione1.0.1
Updated August 7, 2023An underrated technique for studying an unfamiliar codebase is to read through the automated tests. While itโs not the most glamorous part of the codebase, thereโs an enormous amount of institutional knowledge stored in the test files. Automated tests are where past and present developers have codified the specifications the application is expected to operate within.
Most young developers donโt realize that a mature test suite will show you exactly how a program should perform, because each test thatโs added to the suite should be designed to validate a specific part of the program for a specific scenario. As you read through the test cases, youโll see what edge cases the tests handle and what the expected outcomes should be.
Additionally, the assertions in automated tests will show you what the expected output should be when you call a function. Assuming the tests are passing, this gives you a clear picture of how the system works and what application states you should expect.
Codebases 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.