§ 2.8section 8 of 20·~3 min
Code quality
Code is read far more often than it's written. Four cheap habits make yours easy to read:
- Lint and format automatically with Ruff:
uv add --dev ruffuv run ruff check . # finds bugs and bad patterns (unused imports, bare except...)uv run ruff check . --fix # fixes what it safely canuv run ruff format . # consistent formatting, so you never argue about style
- Name things well. Functions are verbs (
issue_book), classes are nouns (Library), booleans read as questions (is_available,has_overdue), and constants are UPPER_CASE (MAX_BOOKS_PER_MEMBER = 3). - Keep functions short, doing one job each. If you need a comment to separate "part 1" from "part 2" of a function, it should probably be two functions.
- Write docstrings for public functions and classes: one line on what it does, plus any non-obvious why.
Peer code review (Day 7). Swap repos with a classmate in the community. Read each other's code and leave at least 3 comments each: one thing done well, one bug or edge case, and one readability suggestion. Reviewing others' code is a skill interviewers test.