1.Code review, clear naming, type annotations, and documentation
Code 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.
Key features
- Code review catches bugs, design issues, and readability problems a solo author misses
- A good name states what it holds or does — retry_count, not n or temp
- A type annotation is documentation a type checker verifies — it cannot silently go stale
- A docstring explains WHY and the contract (inputs, exceptions) — not what is obvious
- Documentation duplicating what code already says adds cost without adding information
Naming — vague vs. clear
- 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
Command
def calculate_shipping_cost(order: Order) -> Decimal:
"""Return shipping cost, free above the $50 threshold.
Raises ValueError if order.items is empty.
"""
...Code review catches what a solo author cannot see; naming, types, and docstrings that explain WHY make code fast to read.