jargon

Design patterns·Who calls whom, and when

the object's behaviour changed after a call and nothing branched — it had swapped the object it was delegating to.

State pattern

Also calledstate, state object, objects for states

Representing each state of an object as a separate class implementing a shared interface, with the object delegating to its current one. It looks structurally identical to strategy, and the difference is who does the choosing: a strategy is handed in by the client and stays, a state replaces itself as the object moves through its lifecycle. That self-transition is the whole distinction and the whole interview answer.

Commonly confused with