How to read fast

Lesson 3 Skip on purpose

5 min read · JavaScript · Quiz

what to ignore (boilerplate, imports, getters) and what never to skip

What you'll learn

  • Skip boilerplate on purpose: imports, constants, plain getters and logs
  • Name the lines you never skip: conditions, deletes, error handling, money and input
  • Spot the boring-looking line that is not boring

You can't read every line, and you shouldn't. Good reviewers skip a lot on purpose, and they know the short list of lines they never skip.

The idea

Skip what is boilerplate: imports of well-known modules, constants, type declarations, plain getters, logging, and glue that only passes things along. These lines are predictable, and a mistake in them is usually loud or harmless.

Never skip conditions, anything that changes or deletes data, error handling (catch, except), money, permissions and user input. And never skip a line that looks like boilerplate but isn't: a getter that changes something, a log line that prints a password. Skipping is a decision, not laziness: you glance, confirm the line is as dull as it looks, and move on.

cart.js
1import { logger } from "./logger.js";2const TAX_RATE = 0.2;34export class Cart {5  constructor(userId) {6    this.userId = userId;7    this.items = [];8  }9  get count() {10    return this.items.length;11  }12  get oldest() {13    return this.items.shift();14  }15  get total() {16    logger.info("total requested");17    const sum = this.items.reduce((s, i) => s + i.price * i.qty, 0);18    return sum * (1 + TAX_RATE);19  }20}
  1. Line 1 Skip: an import and a constant. One glance each (is the module real? is the number sensible?) and move on.
  2. Line 9 Skip: a plain getter. It returns one thing and changes nothing.
  3. Line 13 Stop. This looks like a getter, but shift() removes the first item. Reading cart.oldest twice gives two different items.
  4. Line 17 Don't skip: this is money. Read the arithmetic.

Take away

  • Skip the predictable: imports, constants, plain getters, logging, glue.
  • Never skip conditions, deletes, error handling, money, permissions or input.
  • Glance at what you skip: a boring line that does something clever is the one to stop on.

Quiz: test yourself

7 questions: a quick quiz, then a review drill. Pick an answer to see why it's right.