Strategy: shipping options

Pick an algorithm at runtime without the caller knowing which one runs.

Level Intermediate

What you will see

  1. Two ways to ship, two ways to price
  2. One function, every rule
  3. A strategy is a function
  4. The context delegates
  5. Choosing a strategy
  6. When not to use it

Before / after

Base: strategy-base-goView the diff

Exercises