Wednesday, 28 June 2017

Software Engineering: State Pattern

Behavioural Pattern - State Pattern


Intent
This has a set of behaviours encapsulated in state objects; at any time the context is delegating to one of those states. The client usually knows very little, if anything about the state objects.

Why is this used?
Allows the object to alter its behaviour when its internal state changes. The object will appear to change its class.


UML diagram representation

http://www.devlake.com/design-patterns/state/state2.png

Source code example

https://www.tutorialspoint.com/design_pattern/state_pattern.htm


More to follow...

No comments:

Post a Comment

Software Engineering: Bad Smells! (Smelly code)

Bad Smells! What are bad smells? This refers to any symptom in the source code of a program that possibly indicates a deeper problem.  ...