Solution First

Start with what you'd tell a newcomer.

Thread:
Design patterns
Level:
operational, in the guides column
File:
wiki/patterns/solution-first.md

draft

explained in Writing a pattern

Solution First Sketch in perspective: a large card leans back on a three-legged easel, and a mannequin stands beside it writing with a pencil. Only one band in the middle of the card is written, and it is hatched; the bands above and below it, and a dashed title line at the top, are still blank. The card is a pattern being drafted, with the sections this site's pattern pages use. The written middle band is the solution, the focus: the one thing the writer most wants to share, written first. The blank bands are the problem, context, forces, and consequences, worked out from the solution afterwards. The dashed title line is the name, which the solution says to write last. The writer is anyone with experience to pass on. The metaphor: a pattern written from the middle out, starting from what you'd tell a newcomer and only then explaining when and why.
Fig. 9

Start with what you’d tell a newcomer.

Context

You are writing a pattern from your own experience or someone else’s.

Problem

Writers tend to start at the top of the form, with a name and a context, and fill in the boxes in order. The pattern comes out abstract, and the solution, which is the part worth sharing, ends up the weakest part.

Forces

  • The order a pattern is read in (name, context, problem, solution) isn’t the order knowledge is found in.
  • Alexander identified the solution first, then the problem it solves, then the context, and named the pattern last (The Timeless Way of Building, as read by Iba 2014).
  • A name chosen too early fixes a concept before it’s clear.

Solution

Therefore, write the solution first and the name last, by starting from the one thing you most want to share and working back to the problem it solves and the context where it applies.

Actions

  • Follow the order: solution, actions, problem, context, forces, consequences, name, introduction (Iba 2014; Iba 2021).
  • Find the problem by asking what happens when the solution isn’t there.
  • Check that the solution says both what to do and how.

Consequences

  • Positive: the solution is concrete, and the name captures what the pattern is actually about.
  • Negative: a pattern written this way may overlap one that already exists. Check the pattern table before naming it.

Mark up this page on GitHub