Mnemonic analysis transforms a domain scenario into a more formal representation to expose internal behavior and guide a domain-specific language. The scenario remains readable enough for nondevelopers while making variables, conditions, APIs, and responsibilities explicit. section 3.1.4 section 3.4
Apply the technique by exploring alternative representations rather than accepting the first imperative formulation:
- Write a realistic scenario in a readable pseudolanguage, including inputs, timing, branches, subroutines, and external effects. section 3.1.4
- Identify the domain behavior: read a sensor, classify the value against bounds, store measurements, log failures, and raise alarms. section 3.1.4
- Rework the same behavior as a stream of readings, separating acquisition, conversion, storage, validation, and alerting. section 3.1.4
- Compare the representations to discover a form suitable for an external or internal domain-specific language. section 3.1.4
Temperature monitoring
A thermometer scenario reads once per second, records time, temperature, and device, converts Celsius to Kelvin, stores valid readings, and logs or alarms on out-of-range values. A stream-based version yields readings to a monitor, which validates them and returns either success or a failure message. section 3.1.4
Listing 3.3 Temperature sensor readings scenario
Scenario: readThermometer #1
Description: monitor outside thermometer temperature
Given: outside thermometer @therm
Invocation: once a second
Read @therm, #2
Result: @reading(@time, @temp, @therm)
If @temp < -10C Then #3
register @reading #4
Log @reading #5
Raise alarm "Temperature is too low" #6
Else If @temp > 50C Then #7
register @reading
Log @reading
Raise alarm "Temperature is too high"
Else register @reading #8
Return @reading #9
Inspect the readable sensor scenario and its explicit branches, effects, and returned reading. section 3.1.4
