Designing a Default Branch
A default branch can handle the remaining valid case or report a value outside a decision's supported domain.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Name the reason it runs
For a card with red, green, and blue color codes, a default grayscale display for missing color may be desirable. A misspelled valid code from a data export may require a diagnostic. An exhaustive decision distinguishes known states from truly unexpected input.
Check whether a silent fallback hides errors
Test a missing value and a mistyped code separately. When both produce gray, determine whether a caller needs to identify the faulty export. Missing-value representation gives the code a way to preserve a legitimate absent choice.[1][2]
Choose whether remaining cases are supported
In a label catalogue, known codes can request several named colors and an omitted code can use grayscale. A misspelled code from an external file could also fall into a broad default. Before sharing that branch, decide whether both situations should be treated the same. Start a test with an absent code and another with one invalid spelling. Make their outcomes explicit in a decision table.
Keep a fallback useful when the domain evolves
If a future edition introduces a new code, an earlier view can show an appropriate “unknown” state without claiming it is an existing color. A service applying a mutation may need to reject the unknown code so it can preserve its invariants. These are different boundaries even when both receive the same value. See exhaustive conditions.
Select an example where the response text alone hides an unintended change. Verify that a fallback display does not silently store a replacement value unless that side effect is part of its contract. This lets the view remain usable while leaving invalid data available for diagnosis.