H1.14.4nested conditional form branchesdesignresearch

Too many nested branches make form logic hard to debug

Aliases: combinatorial reveal · state explosion · nested conditions

What it is

One layer of condition (“need invoice → title”) can still be simulated in the head. Three or more—country decides tax ID, tax-ID type decides attachments, attachment type decides a statement—and legal combinations grow by multiplication. Nobody changing one place can enumerate every path. Hard to debug and maintain means product, design, and engineering can no longer give a single answer to “what does the form look like, and what does it submit, under this combination.” Predictability, whether hidden values submit, and reading order all collapse under the tangle; those are symptoms. The object here is branch depth itself.

Why it happens

Each condition is a boolean; nesting is a Cartesian product. Five binary layers are thirty-two visible shapes before multi-select. Working memory—including the author’s—cannot hold that table. Regression relies on paths someone happened to click. A second layer is non-local effects of local edits. Add an option at layer three, and a seemingly unrelated country at layer one suddenly loses or gains a block because they share one reveal function. Without a single “current branch snapshot,” tests are written against screens, not combinations. Fixing a hidden-value-still-submits bug clears a value that should have been kept in another combination. Branches also tangle with validation, drafts, and prefill: a field required in one combination is not even in the DOM in another. Maintenance cost starts to exceed the product gain of “one more condition” around the third layer.

Studying it

Count maximum nesting depth and reachable combinations on an existing form. List visible fields and submitted fields per combination in a decision table, and see whether anyone can finish that table. Compare “flatten into a multi-step wizard with at most one condition per step” with “one page, deep nesting.”

Independent variables: max nesting depth, whether combinations are enumerable, whether branch-snapshot tests exist. Dependent variables: untested combinations, regressions from one change, whether authors can predict a combination’s payload, time to fix.

User tests cannot cover combination explosion and will understate this. Pairwise combination coverage explains this entry better than completion rate. “Users did not complain” does not prove branches are maintainable—users only walk their own path.

Where it stops holding

Tax, clinical, and insurance rules really are deep; they cannot be pretended flat for maintainability. Put deep rules in an engine and in steps, exposing one choice layer per screen, rather than stacking three dropdowns on one screen. Different fields by permission are authorization, not conditional reveal; do not implement them as the same nested ifs. A/B tests that turn on extra condition sets multiply combinations again; freeze depth for the experiment.

Applying it

  • Cap condition depth: at most one layer per screen. Deeper rules go to the next step or a rules engine, not three layers in one render function.
  • Generate a visible-field list and a submit-field list for every legal combination as test snapshots. Changing one condition must run the snapshots.
  • If a new request would fork layer n again, ask first whether it can be a separate task rather than another nest.
  • Verify by drawing the current condition tree and listing combination counts on nodes deeper than two. Pick a combination at random and have someone who did not write the code predict the payload from the copy; a miss means unmaintainable. After folding layer three into the next screen, check that regression moved from “click around” to “snapshots.”

Related

  • Within the group: H1.14.1 Conditional reveal must be predictable; fields must not appear or vanish without warning · H1.14.2 When a filled field is hidden, say whether its data will still be submitted · H1.14.3 Dynamic reveal scrambles screen-reader linear order
  • Adjacent: H1.01 Form length and multi-step · I3.13 Completeness of state machines and illegal states · H1.12 Abandonment and field reduction
  • Search terms: conditional logic · state explosion · decision table

Cards in the same group

Quick Actions

Share

Share this page

ios_share

https://hci.top/en/handbook/H1.14.4