Skip to content

Refactoring UI

Principles, 5 min read

Refactoring UI, by Adam Wathan and Steve Schoger, is the book my team lead recommended: “specific tactics explained from a developer’s point-of-view” (source: Refactoring UI, by Adam Wathan and Steve Schoger). A tactic suits an agent and a judge alike, since “once you know the tactic you just need to notice the problem and apply the solution” (source: Refactoring UI, by Adam Wathan and Steve Schoger). These are the tactics I check a screen against, each in the book’s words with its page.

Why it matters

An agent makes those small decisions on every component it writes, and each value it picks looks fine alone while the components drift apart. With a set chosen in advance, every pick comes from a short list, and a value outside it is a finding.

On this site

The audit of a rejected design found no design system at all: colour variables and nothing else. Each look since has started from one system of tokens, for every colour, size, radius, shadow and duration, and the design record, DESIGN.md, names what each one is for.

What checks it: Impeccable’s detector, which “can check for drift from documented values” (source: Impeccable: Context); it advises and does not block, as Verify with gates explains.

The judge’s visual checklist takes six of the tactics, in both themes, on desktop and phone.

Why it matters

In my builds the agent writes a screen one component at a time, and each component makes its own case for attention, though “when everything in an interface is competing for attention, it feels noisy and chaotic” (p. 36) (source: Refactoring UI, by Adam Wathan and Steve Schoger). Hierarchy shows on the screenshot of the whole screen, never in the diff of one component.

On this site

One family at every size: headings at 600 and titles at 650, text ranked by weight and four inks, and one filled button on a screen.

What checks it: the judge; no gate measures hierarchy.

Why it matters

Every gate an agent runs passes on a cramped screen as on a spacious one, and space added until a component stops looking cramped leaves elements “only given the minimum amount of breathing room necessary to not look actively bad” (p. 67) (source: Refactoring UI, by Adam Wathan and Steve Schoger).

On this site

The record sets the steps; whether a screen has room to breathe is judged.

What checks it: the judge.

Why it matters

A measure is a number, so it can live in one token that every page inherits, instead of in each layout an agent writes and fits the text to.

On this site

Prose capped at 32em at its 17px, about 66 characters, inside the book’s 20 to 35em.

What checks it: the judge.

Why it matters

Contrast is a number a tool can measure, so it is the rule an agent can check for itself, on every page and in both themes, before it claims a screen is done.

On this site

Inks set per theme; by day, the signal’s text is a deeper orange than its light, since the bright orange fails on paper.

What checks it: axe, on every page in both themes, and pixel tests of every text over the light.

Why it matters

A red and a green that both pass the contrast check can still look alike to “someone who is red-green colorblind” (p. 166) (source: Refactoring UI, by Adam Wathan and Steve Schoger), so no contrast check catches a status told by colour alone: the rule has to be written where the agent reads it.

On this site

The Status Rides a Glyph Rule: amber, green and red always come with a drawn glyph and a word.

What checks it: the judge, and a unit test that each status glyph draws a mark of its own, so that the states differ in shape before they differ in colour.

Why it matters

The empty screen is the one an agent sees least as it builds, since every test and screenshot that seeds data skips it, and the one a newcomer meets first.

On this site

The landing ships its first screen in its HTML, with a button to the introduction, so every reader, with or without JavaScript, starts there.

What checks it: the landing’s browser tests, with storage blocked and without JavaScript.

Why it matters

When the agent writes the markup, it writes the words too, and a page that calls one thing by two names reads as two things.

On this site

The words have their own record, the glossary, each term with the words to avoid; Ontology is about keeping them straight in the code.

What checks it: the sweep for retired words, which fails any built page that still carries one.

  1. Refactoring UI, by Adam Wathan and Steve Schoger refactoringui.com
  2. Impeccable: Context impeccable.style