Reading Code Is a Skill
We spend way more time reading code than writing it. Here's how to get better at it.
The Ratio
For every line of code you write, you probably read 10-20 lines. Yet we practice writing code, not reading it.
How to Read Unfamiliar Code
Start with the Entry Point
- Web app? Start at `index.html` or `App.jsx`
- API? Start at route definitions
- CLI tool? Start at the main function
Follow the Data
Pick one feature and trace: 1. Where does user input come in? 2. Where does it get validated? 3. What transforms happen? 4. Where does it end up?
Use Search, Not Browsing
Looking for how authentication works?
grep -r "authenticate\|isLoggedIn\|session" --include="*.js"
Or in VS Code: `Cmd+Shift+F` and search.
Draw It Out
Complex systems need visualization. Draw:
- Which files import which
- Data flow diagrams
- State machines
I use Excalidraw for quick sketches.
Reading for Code Review
Different goal: find issues.
- Does this do what the PR description says?
- Are there edge cases not handled?
- Is this tested?
- Will I understand this in 6 months?
Don't just rubber stamp. Actually trace through the logic.
Learning from Good Code
Find well-maintained open source repos and study them:
- How do they organize files?
- How do they handle errors?
- What patterns do they use?
React's source code taught me more than any course.
Practice
1. Pick a small open source project 2. Set a timer for 30 minutes 3. Try to understand how one feature works 4. Write down what you learned
Do this regularly and reading code becomes natural.