Upgrade to Pro — share decks privately, control downloads, hide ads and more …

State Pattern From GoF

State Pattern From GoF

Prepared for the Melbourne Patterns Group

Chris Bushell

July 07, 2010
Tweet

More Decks by Chris Bushell

Other Decks in Programming

Transcript

  1. Applicability   •  Behavior  depends  on  state   •  Opera<ons

     have  large  condi<onal  statements   which  depend  on  state  
  2. Consequences   •  Localizes  state  specific  behavior.  Avoids  code  

    duplica<on   •  State  changes  are  well  defined,  atomic   opera<ons   •  State  objects  can  be  shared  
  3. Implementa<on   •  Context  or  Concrete  State  defines  transi<ons?  

    •  Table  based  approach  to  defining  transi<ons   •  Singleton,  Flyweight