Lesson 5 of 6 · 10 min · 1 hands-on step

Reading Code You Didn't Write

The real day-one skill. How to find your way around an unfamiliar codebase.

Most of your job is reading

As a developer you'll spend far more time reading code than writing it: understanding how a feature works, finding a bug, reviewing a teammate's change. Juniors who can find their way around unfamiliar code ramp up fast.

A method for any codebase

  1. Run it. Use the app and see what it does.
  2. Read the README and look at the folder structure.
  3. Follow one feature end to end. Find the button in the UI, then the code it calls, then the API, then the database query.
  4. Read the tests. They show how the code is meant to be used.
  5. Use search. Search the whole project for a function name or an error message (Cmd/Ctrl+Shift+F in VS Code).
  6. Take notes and draw boxes and arrows.

Reuse before you write

Before writing something, search for whether it already exists. Duplicated logic means two places to fix every future bug. Reading the existing helper's comment and tests tells you exactly how to use it, like in the practice step.

Use AI as a guide

AI assistants are excellent at "explain this file" and "where is X handled?" Ask, then verify by reading the code it points to. It can misread unfamiliar codebases, and you're the one who needs to understand them.

JavaScript · try it
// A habit: before changing code, write down what you THINK it does, then check.
const prices = [499, 1250, 99];
const total = prices.reduce((sum, p) => sum + p, 0) / 100;
console.log(total); // prediction: 18.48

🧪 Practice

You've joined a team. There's already a well-tested helper, formatMoney(cents, currency). Your task: write invoiceLine(item) using it, so that

invoiceLine({ name: "Keyboard", qty: 2, unitCents: 4999, currency: "USD" }) → "2 × Keyboard: $99.98"

Don't rewrite the money formatting yourself. Read the helper and reuse it.

JavaScript
// ---- existing team code (don't change) ----
const SYMBOLS = { USD: "$", EUR: "€", GBP: "£" };
/** Formats an amount in cents, e.g. formatMoney(1050, "EUR") → "€10.50" */
function formatMoney(cents, currency = "USD") {
  const symbol = SYMBOLS[currency] ?? currency + " ";
  return `${symbol}${(cents / 100).toFixed(2)}`;
}
// -------------------------------------------

function invoiceLine(item) {
}

Output appears here. Press Run or Ctrl/⌘ + Enter.

✅ Check your understanding

  1. You're new and the codebase is huge. What's a good first move?

  2. You find a function that almost does what you need. Best move?

Create a free account to track your progress.