7
Shouts

Atanas Hristov: Design Patterns – State Pattern

published 792 days, 13 hours, 27 minutes ago posted by http://atanashristov.blogspot.com/http://atanashristov.blogspot.com/ 793 days, 9 hours, 19 minutes ago
Tuesday, March 16, 2010 1:20:20 PM GMT Monday, March 15, 2010 5:28:34 PM GMT

The is a behavioural pattern. The behaviour of object changes accordingly to its internal state. We move the logic to property "State" which has method Handle() and call this method. We change the behaviour of the object as we just switch the value of the "State" property.

This is an exapmple of using the State pattern to implement a traffic light.

category: Foundation | clicked: 0 | | source: atanashristov.blogspot.com | show counter code
tags: Design Pattern