Skip to content

Commit bfefa55

Browse files
committed
Update README.md
1 parent 511ebd0 commit bfefa55

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,12 @@
198198
##State
199199
**Intent:** Allow an object to alter its behavior when its internal state changes. The object will appear to change its class.
200200

201+
![alt text](https://github.com/iluwatar/java-design-patterns/blob/master/state/etc/state.jpg "State")
202+
203+
**Applicability:** Use the State pattern in either of the following cases
204+
* an object's behavior depends on its state, and it must change its behavior at run-time depending on that state
205+
* operations have large, multipart conditional statements that depend on the object's state. This state is usually represented by one or more enumerated constants. Often, several operations will contain this same conditional structure. The State pattern puts each branch of the conditional in a separate class. This lets you treat the object's state as an object in its own right that can vary independently from other objects.
206+
201207
##Strategy
202208
**Intent:** Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.
203209

0 commit comments

Comments
 (0)