Design Problems
-
Defining State-Specific Behavior
-
How can an object alter its behavior
when its internal state changes?
-
How can state-specific behavior be defined
so that new states can be added and
the behavior of existing states
can be changed independently?
-
How can conditional
statements that
depend on an object's internal state
be avoided?
Refactoring Problems
-
Complicated Code
-
How can conditional
statements that
depend on an object's internal state
be eliminated?
Replace State-Altering Conditionals
with State (166)
[JK05]