Skip to content

A reading order for inherited code

A. Lee11/22/20263 min read
Cover for the article “A reading order for inherited code”

Inheriting a codebase feels like being handed a novel with the first hundred pages missing. The instinct is to start reading from the beginning and hope the plot returns. That rarely works.

A better approach is to read for structure first. The goal is not to know every file. The goal is to build a map good enough to make one safe change, then another.

Run it before you read it

Get the application running before you form an opinion about the code. Follow the setup notes, or write them if they are missing. Open every screen. Click the main flow. Watch the logs while you do it.

Runtime behaviour narrows the search space. If the export button calls a queue, you know where to look. If the settings page never writes anything, you have found a question worth asking before you touch the settings code.

Write down every step that failed. Those failures are the first entries in your map.

Follow one request

Choose one user action: sign in, save a record, start a checkout, load a report. Follow it from the click to the database and back.

At each boundary, write down the name of the function, the module, or the service that hands work to the next layer. You do not need to understand the implementation yet. You need the shape of the path.

When the path is clear, repeat it once. Two paths that share a boundary tell you where the application's real seams are.

Find where money moves

In a commercial product, the money path deserves its own reading. Find the checkout, the payment provider call, the webhook handler, and the code that grants access after payment.

Then read the failure branches. What happens when the provider times out? When the same event arrives twice? When a refund lands after the file was delivered? These paths are usually shorter than the feature code and far more expensive to get wrong.

If you cannot find the money path, stop and find it before you change anything else.

Read the tests that fail

Do not read the whole test suite. Run it. Failures show you where the repository's assumptions and its current behaviour have drifted apart.

Then read a few tests that pass. A test that asserts a real outcome is documentation you can trust. A test that only checks that a function was called is a rumour.

If the suite is green but the application is broken, the tests are measuring the wrong thing. That is a finding, not a nuisance.

Make a deletion list

Before you add anything, list what can go: dead feature flags, unused dependencies, duplicate helpers, commented-out code, screens nobody can reach.

Deleting is the cheapest way to understand a system. Every removed path is one less thing to keep in your head. Keep the list visible and remove one item at a time, with a test or a manual check after each change.

Write the map you wish you had

Keep one page in the repository: entry points, background jobs, external services, data stores, scheduled tasks, and the person or team that owns each one. Add the commands that actually work.

The next person may be you in a year. A good map is the kindest thing you can leave behind.

More from the journal

Practise on a codebase you can keep.

GutSync's source is free: a Flutter app with local storage, food data, and platform shells. Read it end to end.

Get GutSync source — free