bcquality/community/knowledge/performance
António Silva 63bd69d7e5 Add case true of pattern for long condition chains
Follow-up from PR review: nested if is the right answer for two or three
dependent conditions, but past that the nesting becomes the problem. AL's
case statement is the flat alternative — the control statements
documentation states a value set "must be an expression or a range" and
that the first matching value set executes, so case true of / case false of
accept boolean expressions and stop at the first match. That is the
laziness the boolean operators do not provide.

Adds case-true-of-for-long-condition-chains.md with good/bad AL companions:
case false of for guard chains where every condition must hold, case true of
for first-match dispatch. The bad sample shows both failure shapes — a
five-level if ladder, and the worse escape of collapsing it into an and
chain, which trades nesting for a real defect.

Cross-links both articles, and adds the threshold to the short-circuit
article's Best Practice so following it does not lead to a deep ladder.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-25 12:00:14 +01:00
..
boolean-operators-do-not-short-circuit.bad.al Add community knowledge on AL boolean operators not short-circuiting 2026-08-24 10:19:09 +01:00
boolean-operators-do-not-short-circuit.good.al Add community knowledge on AL boolean operators not short-circuiting 2026-08-24 10:19:09 +01:00
boolean-operators-do-not-short-circuit.md Add case true of pattern for long condition chains 2026-08-25 12:00:14 +01:00
case-true-of-for-long-condition-chains.bad.al Add case true of pattern for long condition chains 2026-08-25 12:00:14 +01:00
case-true-of-for-long-condition-chains.good.al Add case true of pattern for long condition chains 2026-08-25 12:00:14 +01:00
case-true-of-for-long-condition-chains.md Add case true of pattern for long condition chains 2026-08-25 12:00:14 +01:00