Code review, clear naming, type annotations, and documentation
coreintermediateCode review is a second person reading code before it merges, catching what the author could not see. Clear naming, type annotations, and documentation make that review — and every later reading — fast, not a slow reverse-engineering act.
Think of it as
Code is read far more often than it is written — a reviewer, a future maintainer, or the same author six months later, all reading without the context that was in the author's head while writing. Naming, types, and docs are that missing context, written down once instead of re-derived every time.
What we're doing: Contrast a vaguely-named, undocumented function with one carrying clear naming, a type annotation, and a docstring that explains the non-obvious rule.
- 1
- calc(o) tells a reader nothing — what does it calculate? What is o? A reviewer has to read the whole body to find out.
- 7
- The name alone tells a reader what this does; -> Decimal tells them what comes back, checked by a type checker, not just claimed in a comment.
- 8
- The docstring states the ONE fact not obvious from the code itself (the $50 threshold rule) — it does not restate what the code already says plainly.
Why this works: Both functions do the same thing — but a reviewer (or a future reader) understands the second one in seconds, from its name and one-line docstring alone, without needing to trace through the logic first.
Writing a docstring that just restates the code
Wrong
Better
What you see: The docstring takes time to write and read but tells the reader nothing they could not already see from the function signature.
Why: A docstring earns its keep by stating something the signature and code do NOT already make obvious — a raised exception, a non-obvious edge case, a caller contract. "Get a user" adds nothing over the name get_user already saying exactly that.
- calc(o)
- Vague name — what does it calculate?
- No type hints — o could be anything
- No docstring — the $50 rule is hidden in the body
- calculate_shipping_cost(order: Order) -> Decimal
- Name states exactly what it does
- -> Decimal is checked by a type checker, not just claimed
- Docstring states the one non-obvious rule, nothing else
Naming — vague vs. clear
Together
Remember: Code review catches what a solo author cannot see; naming, types, and docstrings that explain WHY make code fast to read.
See also: function design and structure · basic annotations

