Monday, February 10, 2014

State Pattern, a Behavioral Design Pattern

One of the more intriguing design patterns I read about while perusing the software design pattern wiki was the state pattern in the category behavioral design patterns.

This pattern hinges on a characteristic of a programs objects called state. The state of an object (can be an object itself) is used to allow the original object to have multiple behaviors. Part or all of the behavior of the object is actually dependent on the state variables or state object of the original.

This simplifies the way in which the program has to handle these objects. The program need only update the state of the objects (although I suppose they could update it themselves in some implementations), and then treat the object the same regardless of the state and the object will adjust its behavior accordingly.

I find this design pattern to be particularly powerful in one main way--it allows for a large conceptual and programatic abstraction of each object that aligns well with my understanding of an "actor" model of conceptualization. Particularly, a program can be conceived and developed as a stage for the interaction of various actors (sometimes objects), and define the rules for the interactions of the actors which algorithmically results in desired behavior.

One area I have used a concept like this in the past is in experimenting with multi-agent robotic algorithms.

The state design pattern is particularly powerful in this setting, as we can allow the actors to perform various roles or behaviors based on the state of the system which allows for more complex behavior and interaction definitions.

I will definitely be considering the use of this pattern in the future.

No comments:

Post a Comment