Tuesday, September 7, 2010

State Pattern

So an RIA page needs its state to be driven by a server side engine, lots of if/else statements are going to happen for sure. The State pattern is your friend here. It allows a server class to have a set of state objects, of which one is current at any time. Each state controls the behavior of the class for a certain command, and determines the next state to transition to.
Any changes to the system behavior can be made just by modifying the states. Saved me a lot of messy code.

No comments: