The EARS patterns
The classifier reads each requirement and assigns it one pattern. A requirement
is built from a system, a shall response, and zero or more optional clauses:
a trigger (WHEN), a state (WHILE), a condition (IF ... THEN), and a
feature (WHERE). The pattern follows directly from which of those clauses are
present.
There are five canonical patterns plus one combinator:
| Pattern | Clause present |
|---|---|
| Ubiquitous | none |
| Event-driven | WHEN only |
| State-driven | WHILE only |
| Unwanted | IF ... THEN only |
| Optional | WHERE only |
| Complex | any other combination |
When exactly one optional clause is present, the requirement takes the matching single-clause pattern. With no optional clauses it is ubiquitous. With more than one optional clause, or any combination the single-clause rules do not name, it is Complex.
The examples below are the finance options demo, references/finance_options/,
which exercises every pattern in order.
Ubiquitous
Section titled “Ubiquitous”An invariant the system always holds, with no qualifying clause.
FIN-001 The option pricer shall produce non-negative call prices.The system is option pricer, the response is produce non-negative call prices. With no WHEN, WHILE, IF, or WHERE, the requirement is
ubiquitous.
Event-driven
Section titled “Event-driven”A response triggered by an event, introduced by WHEN.
FIN-002 WHEN market data arrives, the implied-volatility surface shall be within tolerance.The trigger is market data arrives. Because the trigger is the only optional
clause, the pattern is event-driven.
State-driven
Section titled “State-driven”A response that holds while the system is in a given state, introduced by
WHILE.
FIN-003 WHILE the exchange is open, the portfolio delta shall be at most the limit.The state is the exchange is open. With the state as the only optional clause,
the pattern is state-driven.
Unwanted
Section titled “Unwanted”A response to an unwanted condition, written as IF ... THEN .... The IF
clause and its , THEN marker are required together.
FIN-004 IF an order breaches the position limit, THEN the order gateway shall reject the order.The condition is an order breaches the position limit. With the condition as
the only optional clause, the pattern is unwanted. Responses that begin with
reject, raise, fail, or error are additionally marked as error
rejections.
Optional
Section titled “Optional”A response that applies only where a feature is enabled, introduced by WHERE.
FIN-005 WHERE same-day settlement is enabled, the settlement clock shall be bounded by the window.The feature is same-day settlement is enabled. With the feature as the only
optional clause, the pattern is optional.
Complex
Section titled “Complex”Any requirement that combines more than one optional clause. The clauses are
read left to right and may mix WHILE, WHEN, IF ... THEN, and WHERE.
FIN-006 WHILE the exchange is open, WHEN a quote changes, IF the quote is firm, THEN the call price curve shall be monotone-increasing.This carries a state (the exchange is open), a trigger (a quote changes),
and a condition (the quote is firm) on one system. Because three optional
clauses are present, the pattern is Complex.
Reading clauses
Section titled “Reading clauses”Each optional clause ends at a comma, except IF, which runs to its , THEN
marker. The clause keywords are matched case-insensitively. After the optional
clauses, the remaining text up to shall is the system, which must start with
the, and everything after shall is the response.