Presentation is loading. Please wait.

Presentation is loading. Please wait.

State Design Pattern 1.

Similar presentations


Presentation on theme: "State Design Pattern 1."— Presentation transcript:

1 State Design Pattern 1

2 State Pattern Intent Allow an object to alter its behavior when its internal state changes The object will appear to change its class

3 <<interface>>
Class Diagram The State interface defines a common interface for all concrete states; the states all implement the same interface so that are interchangeable. <<interface>> State Context Request() Handle() ConcreteStateA ConcreteStateB state.Handle() Handle() Handle() Whenever the request() is made on the Context it is delegated to the state to handle ConcreteStates handle requests from the Context. Each ConcreteState provides its own implementation for a request. In this way, when the Context changes state, its behavior will change as well.

4 Participants Context State ConcreteState
Defines the interface of interest to the clients Maintains an instance of a ConcreteState subclass that defines the current state State Defines an interface for encapsulating the behavior associated with a particular State of the Context ConcreteState Each subclass implements a behavior associated with a State of the Context

5 ?

6 References


Download ppt "State Design Pattern 1."

Similar presentations


Ads by Google