Use the State pattern when…

  • You have objects that:
    • Will change their behavior at runtime, based on some context
    • Are becoming complex, with many conditional branches
  • You want to:
    • Vary the set of handlers for an object request dynamically
    • Retain flexibility in assigning requests to handlers