What is state pattern used for?

The state pattern is used in computer programming to encapsulate varying behavior for the same object, based on its internal state . This can be a cleaner way for an object to change its behavior at runtime without resorting to conditional statements and thus improve maintainability.

Read more