The State Design Pattern

joshcandish 2,782 views 11 slides Sep 29, 2014
Slide 1
Slide 1 of 11
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11

About This Presentation

A look into the state design pattern in C#.


Slide Content

State Design Pattern Joshua Candish

Introduction What is the state design pattern How does it work When to use it/What it does for us An industry use of the pattern Research Poster Code walkthrough

The State Design Pattern It allows an object to alter its behaviour when its internal state changes.

Explained Context: The context maintains an instance of a concrete state subclass that defines the current state State: Defines an interface for encapsulating the behaviour associated with a particular state of the context.   Concrete State: Each subclass implements a behaviour associated with a state of context.

Think about it like this States Interactions

When Not many negatives Gaming makes good use Easy to test

Xero’s Transaction Engine States : Raise, Transfer, Pay, Reconcile, etc... Interactions : Play, Rewind, Replay, etc...

References Abd -El-Hafiz, ,S.K., Shawky , D. M., & El- Sedeek , A. (2008). Recovery of object-oriented design patterns using static and dynamic analyses. International Journal of Computers & Applications, 30(3), 220-233. Retrieved from ProQuest . Freeman, E., & Robson, E., & Bates, B., & Sierra, J. (2004) Head first design patterns. O’Reilly Media . Gamma, E., & Helm, R., & Johnson, R., & Vlissides , J. (1995) Design patterns: Elements of reusable object-oriented software. Addison-Wesley Publishing Company . Seiter , L. M., Palsberg , J., & Lieberherr , K. J. (1998). Evolution of object behavior using context relations. IEEE Transactions on Software Engineering, 24(1), 79-92. Retrieved from ProQuest . State .NET design pattern. (2014). Retrieved 28 August 2014 from www.dofactory.com/net/state-design-pattern Derek Banas . (2012, October, 16). State design pattern. Retrieved 28 August from www.youtube.com/watch?v=MGEx35FjBu

Questions?

Let’s look at in practice