A4.1 · Specification by Example · dive 3
Removing ambiguity
An abstract requirement is a set of possible readings. The work of specifying by example is choosing the cases that narrow that set to one — before a line of code is written.
“Handle a request with no signed-in learner” could mean a 404, a crash, showing
another learner's courses, or a redirect. Each worked example rules out the readings it contradicts. Slide on
the right to add examples and watch the surviving readings fall — the protected
/my/courses closes on one: a redirect.
Add examples · watch the readings fall to one
A requirement is a set of readings
Ambiguity is not vagueness. “Handle a request with no signed-in learner” is a perfectly clear English sentence; what it lacks is a decision. It admits a 404, a crash, showing another learner's courses, a redirect — each a legitimate reading of the same words. The requirement names a set of possible behaviours and stops, leaving the choice to whoever builds it.
Removing ambiguity is the act of adding worked examples until exactly one reading survives. Each example is a concrete case with a stated result, so it contradicts every reading that would have produced a different result — and rules them out. Add the case “a request with no signed-in learner is redirected” and the 404, the crash, and showing another's courses are all gone. The set has been narrowed to one, and it was narrowed before a line of code was written.
- ambiguity
- A requirement that admits more than one reading. The words are clear; the decision is missing.
- a reading
- One behaviour the requirement could mean. "Handle a request with no signed-in learner" has at least four — a 404, a crash, showing another's courses, a redirect.
- removing ambiguity
- Adding worked examples until exactly one reading survives. Each example rules out the readings it contradicts.
- before code
- The narrowing happens in the spec, ahead of the build, so the agent has one reading to implement and no choice to invent.
An example removes the readings it contradicts; enough examples leave one. The skill is choosing cases that, together, cover the behaviour and converge — not piling on cases that all say the same thing.
Ambiguous, or a pinning example
The test of a statement in a spec is simple: does it leave many readings open, or does it pin one? An abstract phrase — “handle bad input,” “show something reasonable” — opens readings; a worked example — “a request with no signed-in learner is redirected” — closes them to one. The same spec usually carries both: the prose frames the intent, the examples pin the behaviour.
Select a statement below. The figure reports whether it is an ambiguous requirement (many readings) or a pinning example (one reading), and why. A spec that is all prose can be argued with; a spec whose examples pin every behaviour cannot.
Classify a statement · pick one
A prose requirement opens readings; a worked example closes them — the spec needs both, but only the examples pin the behaviour.
On the Portal
On the Portal — the learning platform this course builds — the spec for the learner-enrollments
page opens with the abstract intent: serve a learner their own courses and handle a bad request gracefully.
Left there, “gracefully” is a set of readings. The spec closes them with worked examples:
Portal.Enrollment over an enrolled learner, a learner with no enrollments, and an
unauthenticated request, each with a stated result. The not-signed-in case pins the one reading that
survives — a redirect, never another learner's courses.
The fragment below is spec text: the abstract Definition-of-Done phrasing set against the pinning Given/When/Then settled at F6.5 · Views with HEExThe HEEx rung that server-renders the catalog and reconciles the learner route into the protected /my/courses.View the spec ladder →. The contrast is the whole lesson — one line read many ways, three examples that leave one.
# the abstract intent (one line, many readings until pinned): # "the page must handle a bad request gracefully" # readings: a 404? a crash? another's courses? a redirect? ← undecided # stories (F6.5) — the worked example that pins ONE reading: # Given a request with no signed-in learner, # when GET /my/courses, # then it redirects — never another learner's courses. surviving_reading = "redirect, never another's courses" # the one the examples leave removed = :the_other_three # 404, crash, another's courses — ruled out
The principle
Choose worked examples until exactly one reading of the requirement survives. The examples remove the ambiguity in the spec, before the agent builds.
On the Portal
The Portal pins “handle a bad request to /my/courses” to three
Portal.Enrollment cases; the redirect reading is the one that survives, and it is
the acceptance check.
The examples narrow a requirement's readings to one in the spec — so the agent implements a decision, not a guess.
Recap — many readings to one
A requirement is a set of readings; ambiguity is the missing decision, not vagueness. Removing it is adding worked examples until exactly one reading survives, each example ruling out the readings it contradicts — and the narrowing happens in the spec, before a line of code is written. The Portal closes “handle a bad request to /my/courses” to the redirect reading. That closes the module: examples are the specification, they are living documentation that cannot drift, and they remove ambiguity. The next module names which artifact carries which part of all this.
Next, module A4.2 · The triad: spec, stories, agent brief — which artifact answers which question, so no document is crammed. Return to the A4.1 module hub to continue.
References
The sources behind removing ambiguity, and where it connects in the course.
Sources
- Adzic, G. — Specification by Example — worked examples that remove ambiguity before the build.
- Gherkin reference — Given/When/Then as the form a pinning example takes.
- Cohn, M. — User Stories Applied — the conversation a story records and the examples that settle it.
Related in this course
- A4.1 · Specification by Example — the module hub.
- A4.1.2 · Living documentation — the previous dive.
- A4 · The spec layer — the chapter.
- A4 · The spec ladder — the F6.5 rung this dive cites, across the iterations git recorded.
- A2.04 · Acceptance with Given/When/Then — the form a pinning example is written in.
- Companion · Phoenix (F6) — the real chapter whose F6.5 rung grounds this dive's /my/courses examples.