How does the Strategy pattern differ from the State pattern even though both change an object's behavior at runtime?
-
A
Strategy changes behavior based on internal state transitions; State uses external configuration
-
B
Strategy encapsulates interchangeable algorithms chosen by the client; State encapsulates behavior tied to internal state transitions
-
C
Strategy uses inheritance; State uses composition
-
D
Strategy applies only to sorting algorithms; State applies only to UI components