Design Patterns · Senior · Question 38 of 75

How do you use Strategy for A/B tests without cluttering components with conditions?

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.

Further reading

Problem with a question

Design Patterns · Senior · question 38

Test yourself

Take the Design Patterns · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz