State (objects for states)Pattern

  1. Summary

      1. Allow an object to alter its behavior when it’s internal state changes. The object will appear to change its class.

      2. This is a clean way for an object to partially change its type at run-time

      3. An object-oriented state machine

      4. wrapper + polymorphic wrappee + collaboration

  2. Overview Tutorial

  1. Example

      1. Cursor changes it shape based on underlying context

  1. Specific Consideration

    1. Strategy VS State Pattern

        1. Both strategy and state looks same from class diagram prospective but intent is deferent

        2. Strategy defines class behavior at initialization time while state pattern changes the behaviors any time during the object life cycle bases on object internal state

        3. In strategy client binds behavior with class but in strategy object itself reload it behavior based on its internal state.