State Pattern from GoF

1,836 views

Published on

State Pattern from Gof, by Chris Bushell, x

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,836
On SlideShare
0
From Embeds
0
Number of Embeds
30
Actions
Shares
0
Downloads
18
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

State Pattern from GoF

  1. 1. State Pattern From GoF Chris Bushell 7 th July 2010
  2. 2. Motivation <ul><li>“Allow an object to alter its behavior when its internal state changes” </li></ul>
  3. 3. Code
  4. 4. Applicability <ul><li>Behavior depends on state </li></ul><ul><li>Operations have large conditional statements which depend on state </li></ul>
  5. 5. Participants
  6. 6. Collaborations <ul><li>Context and Concrete State </li></ul><ul><li>Context is primary interface for clients </li></ul>
  7. 7. Consequences <ul><li>Localizes state specific behavior. Avoids code duplication </li></ul><ul><li>State changes are well defined, atomic operations </li></ul><ul><li>State objects can be shared </li></ul>
  8. 8. Implementation <ul><li>Context or Concrete State defines transitions? </li></ul><ul><li>Table based approach to defining transitions </li></ul><ul><li>Singleton, Flyweight </li></ul>

×