All challenges
Multiple ChoiceIntermediate 45s

OCP via data, not classes

Which change to a pricing engine is usually the cheapest way to add a new promotion without modifying existing code?
Options
  1. 1Create a new subclass of the engine for each promotion
  2. 2Copy the engine file and edit the copy
  3. 3Model promotions as data-driven rules evaluated by one stable engine
  4. 4Add another boolean flag to an ever-growing options struct

Think you can answer under pressure?

Get matched and answer live questions in 3-minute 1v1 battles. Elo ranking, badge tiers and bragging rights on the line.

Play this in a 3-minute battle