More than 80% of code is useless for us in a codebase, so how to find the remaining influential code?
Guided by Purpose
Being guided by purpose will help you to be more resilient - finding the code involved in what you need, then reinventing it for your objective.
Read the Documentation
The first place I start with a new project is reading over any available documentation or README files. This allows me to become familiar with the setup, functions, style, and other important parts of the codebase. Some parts of the documentation might be out of date, but seeing the evolution of code can also help to understand the project’s history.
- Official website
Read the Commit Messages
Reading over commit messages for a particular file in which you are working could help you understand the existing code. From the commit history, you might be able to find a pull request that has further detail on any changes and on the developer that made them. If that developer is still on the project, you may be able to ask them some questions about their code.
A great way to gain knowledge of a project when starting out is to pair with a developer on your team who is more familiar with the codebase. This person can provide high-level insight about particular design patterns, testing, processes, and third-party code that are relevant to the project. They can also give you more historical context about the project and why certain choices were originally made. If you feel inclined, take this new knowledge and add it to the project’s shared documentation—it will help make onboarding other new developers in the future much faster.
Read the Tests
Look to see if your project has unit, integration, or functional tests. Run the tests and look over what each one is doing. Reading over the tests for what I’m working on helps to get a sense of the functionality and any edge cases or defects.