How to Read a Codebase You've Never Seen: A First-Week Map
It's your third day. Your first ticket arrives: "Change the message people see when their password is too short." It sounds like a five-minute job. Then you open the project and see hundreds of folders, and you have no idea where to start.
That feeling is normal. In most coding jobs, you spend more time reading code other people wrote than writing new code. This notebook from DevGrid Staffing LLC shows a calm way to find your way around.
A "codebase" is all the code for one project, kept together in one place. You don't need to understand all of it. You need to understand one path through it.
Start with what the user sees
- Find the exact words on the screen. Copy the text the user sees, for example:
Password must be at least 8 characters. - Search the whole project for those words. Open a terminal in the project folder and run:
git grep -n "at least 8 characters"git grepsearches every file the project tracks. The-npart shows the line number of each match. - Open the file it finds. This is your starting point. Now you have one thread to pull.
No match? The text may live in a separate "translations" file. Search a shorter part, like "at least".
Follow the trail, one step at a time
- Look at what is around the match. Is the text inside a function? A function is a named block of code that does one job. Write down its name.
- Search for that name. Run
git grep -n "checkPassword"(use the real name you found). This shows where the function is used, so you can see who calls it. - Stop after three or four steps. You are building a short path, not a full map of the project.
- Write the path in your notes. Keep it plain, like this:
signup page -> form handler -> checkPassword() -> error message
Ask the history for help
Code has a past, and Git (the tool that saves every version of the code) remembers it.
- See recent changes to the file:
This lists the last five saved changes to that one file, one line each.git log --oneline -5 -- path/to/file - See who last touched a line:
This shows who last changed lines 40 to 50, and when. "Blame" sounds harsh, but it just means "who can I ask?"git blame -L 40,50 path/to/file - Read one old change in full. Copy an ID from the log and run
git show <id>. You'll see why the code looks the way it does.
The password ticket, start to finish
Back to the password ticket. Here is how the steps could play out.
- You search for the message and find it in a file of form rules.
- Next to it, you see the number
8in a line namedMIN_PASSWORD_LENGTH. A name in capital letters like this often means a "constant", a value that is set once and doesn't change. - You search for
MIN_PASSWORD_LENGTHand find it used in two places: the sign-up form and the reset-password form.
That second place matters. If you had changed only the sign-up message, the two forms might say different things. Your short path just saved you from a confusing bug.
Now write a note before you code: "The message and the rule live in one file. Both forms use it. I'll change the text in one place." Post that note in the team chat and ask if it sounds right. You also ask whether there are tests for that file. You now have a plan, and your team can see how you think.
Habits that make the next ticket easier
- Keep one notes file per ticket with the paths you traced.
- When something confuses you, write the question down instead of fixing it right away.
Where DevGrid fits in
DevGrid Staffing LLC focuses on early-career and junior engineering roles. If you're looking at DevGrid Staffing LLC careers, this is the skill we hope you bring: patience with code you didn't write.
Your five-minute practice
Open any project, pick one message you can see on the screen, and use git grep to trace it back three steps. Write the path down in one line.
From the DevGrid Staffing LLC engineering notebook · devgridstaffing.com
