design-patternsstrategy.mdSettings
design-patterns, updated 15 Aug 2026

Strategy: Choosing How to Forage at Runtime

Placeholder prose. Nectar, pollen, water and propolis are collected differently, but the trip out and the trip back are the same. The opening section sets up the analogy and states the pattern in one sentence.

Second paragraph of placeholder body copy. It names the conditional the pattern replaces and the test suite that gets shorter as a result.

The branch that hides the algorithm

Placeholder lead-in to the code sample below.

hive/forage.ts
function forage(kind: string, field: Field) {
  if (kind === "nectar") { … }
  else if (kind === "pollen") { … }
  else if (kind === "water") { … }
  // the trip logic is duplicated in all three
}

A conditional that never shrinks is a strategy waiting to be named.

Name the varying part

Closing placeholder paragraph. It restates the pattern, concedes where a conditional is simply clearer, and hands off to the next article.