The state behavioral pattern allows you to simplify your code when you have different modes of operation.
See All 304 Episodes of "Take Up Code"