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
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.