MΓ³dulo 23 Β· Design Patterns (All 23 GoF) β LecciΓ³n 21 de 23 Β· ~6 min
Strategy
Strategy: swap interchangeable algorithms at runtime
Problem: one operation has several interchangeable implementations, chosen per call.
PawWalk scenario: pricing β flat, surge, or member-discount β picked per booking.
Say it plainly: in Ruby a strategy is usually just a lambda or any callable. You don't need a
Strategyclass hierarchy; you inject a block.