This article describes the State design pattern. This is a behavioral design pattern, a category of design pattern used by software engineers, when writing computer programs.
The State pattern is a design pattern, used in software engineering to simplify large swathes of conditional code. Instead of a class having large chunks of code that only get executed under certain conditions (states), why not split it into derived classes that represent those states. It is defined as a behavioral design pattern, because execution is performed by a selected derived class, depending on it funtion.
↑ Return to Top
This pattern helps to keep code tidy and reduce conditional processing. It enables the object to polymorph into another object.
An example of this pattern would be in the definition of an art package toolbox. Each toolbox item (pen, pencil, brush) performs the same basic actions, but performs them in a different way (sharp line, fuzzy blob).
XAML guy edited Revision 3. Comment: tweak
XAML guy edited Revision 2. Comment: tidied sections
XAML guy edited Revision 1. Comment: tweak
XAML guy edited Original. Comment: spell
Are these articles to be updated by members?
You are welcome to :)