ActionScript 3.0 Design Patterns

(Chris Devlin) #1
Summary | 397

Summary


We’re used to thinking in noun-verb pairs, and so designs using the verb element of


a pair may take a bit of getting used to. You can think of a state as a “state of action”


such as a video playing or recording. However, you can also think of a state as a


“state of rest” or “inactivity.” Likewise, transitions between states have a verb-cen-


tric character to them.


The focus of the State design pattern has always been on what is done rather than the


characteristics of the objects. Additionally, statecharts are an incredibly easy and


effective way to design applications. It begins with the part that is often left to the


end of a project—making all of the connections between the different elements.


Once the statecharts are complete, casting the project in State design patterns terms


is equally easy because the structure of the class is so simply organized. Each state


will have its own class, and the classes are made up of the different transitions


defined in the state interface. All that’s left is the context class to pull it all together.


So if your project involves different actions that need to be organized and coordi-


nated, consider a state machine using the State design pattern.

Free download pdf