October 2018
Intermediate to advanced
370 pages
9h 15m
English
According to the state pattern, we should implement each state of a system as a derived object. We should also declare a class that contains a property that represents the current state and methods that invoke transitions between states. It's worth mentioning that we can consider the state pattern as an extension of the Strategy pattern because methods can change their behavior depending on the state. The following diagram shows what an implementation of this pattern may look like:

The diagram contains classes such as UnauthorizedState, ProfileCompletedState, and SignedUpState, which all represent a certain state of a program. These ...
Read now
Unlock full access