GoF Definition: Allow an object to alter its behavior when its internal state changes. The object will appear to change its class.
The concept is best described by the examples that follow.
Consider a network connection for the moment. Here the object (that is responsible for communication) can be in various states (e.g., already a connection is established, a connection is closed, or the object is listening through the connection). We can also think of a traffic signal in this context.
The above example is applicable in the computer world also. Let us look at an additional ...