Skip to the page

Collaboration and heavy clients · senior

Case study: spreadsheet / data grid (Google Sheets)

A strong spreadsheet design stores only non-empty cells in a sparse map, renders only visible rows and columns (DOM virtualisation or canvas), recalculates only the dependents of a changed cell in topological order with cycle detection, and fetches large data in windows.

The notes

What you must know

  • Cell model: Map keyed by 'row:col' → { raw, value, format }; empty cells are not stored.
  • Rendering: virtualise both rows and columns; for very large grids draw on canvas with a DOM overlay for the active editor and an off-screen accessible grid model.
  • Formulas: parse to an AST; keep a dependency graph (cell → dependents); on edit, collect the transitive dependents and recalculate them in topological order; a cycle becomes an error cell (#REF!/#CYCLE); heavy recalculation runs in a Web Worker.
  • Big data (10 million rows): never download everything; fetch blocks of rows on scroll, keep an LRU of blocks, cancel requests for rows scrolled past, sort and filter on the server.
  • Editing: a selection model (ranges), keyboard navigation, copy/paste as TSV, an undo stack of commands.
  • Collaboration: cell-level operations with server ordering and last-writer-wins per cell (like Figma's per-property rule).
  • Frozen rows/columns, column resize, number formats via Intl.

The red pen

Common traps: mistake → fix

  • Mistake: Render every cell

    Fix: a million DOM nodes.

  • Mistake: Recalculate the whole sheet on each edit

    Fix: slow; only dependents need it.

  • Mistake: Recursive evaluation without cycle checks

    Fix: stack overflow or infinite loop.

  • Mistake: Download the full dataset

    Fix: memory and time explode.

Easy to hard

Questions interviewers ask, easy to hard

  1. Design Google Sheets' frontend.
  2. DOM virtualisation or canvas? Why?
  3. A1 changes. Which cells recalculate, in what order?
  4. Render 10 million records from an API.

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview