Practice & Assessment
Test your understanding of Reading Code You Didn't Write
Multiple Choice Questions
6A function is named getUserPermissions but also logs a security audit event to a database. What does this indicate?
You see a comment that says // increment counter. What is wrong with it?
What does the _tokenCache naming pattern (leading underscore) conventionally signal in object-oriented code?
When tracing data through async function calls, what does hitting an await keyword indicate about the data at that point?
A FIXME comment reads: FIXME: race condition under high load — ticket #892 (added 2021-06-10). How should you treat this when reading the code?
What is the main advantage of annotating code as you read it, compared to just reading it?
Coding Challenges
1Annotate a Real Open-Source Function
Navigate to https://github.com/expressjs/express/blob/master/lib/router/index.js. Read the route function (approximately line 490). Add inline annotations to every non-trivial line explaining what it does and why. Save your annotated version as annotated-route.js. Your annotations must: explain each parameter's purpose, identify all side effects, note what the function returns and when, and flag any TODOs or unusual patterns you find. Input: the raw source file. Output: annotated-route.js with inline comments. Do not change any code — only add comments. Time estimate: 20–25 minutes.
Mini Project
Code Reading Journal
Pick any open-source Node.js or Python project on GitHub with at least 500 stars. Read its core module (the largest non-test, non-config file). Produce a READING_JOURNAL.md with these sections: (1) Function Inventory — list every exported function, its signature, whether it's pure or has side effects, and a one-sentence description. (2) Data Flow Map — trace the main data transformation from entry point to output in plain English. (3) Naming Analysis — identify 3 names that clearly communicate intent and 3 that are unclear or misleading, with explanations. (4) Comment Quality — find 2 comments that explain why and 2 that only describe what, with your assessment. (5) Open Questions — list 3 things you don't understand after reading, with a hypothesis for each. Use all Module 2 techniques: signature reading, data flow tracing, naming convention analysis, and annotation.
