Design Patterns · Senior · Question 38 of 75
How do you use Strategy for A/B tests without cluttering components with conditions?
- ✓Correct answer: Choose the implementation at the boundary and pass it inward
- 2Write
if (experiment === 'B')in every affected component - 3Deploy a separate app build for each variant
Explanation
A factory or provider picks the component/strategy by flag, and the rest of the code works with a common interface. After the experiment, the losing variant is removed in one place, without hunting for conditions across the project.