Recipe for State.

1)write it out, figure out how the classes will interact, what your states will be, and what actions will create the transintions.

2) Create the interface with the State methods

3) follow this with the classes that represent the different states and implement the state interface, override methods where necessary

4) create the necesarry reference variables in the constructor of the subject of this pattern, the one whose state is going to be changing.

5)using these reference variables, you can now implement the given methods in your subject, but use the state reference variable to execute the methods, so that when it is executed, the output will be appropriate to whatever state the object is in.

6) I think this may have already been done somewhere along the way, but just in case, be sure you set up the code representing the actions that will create the shift changes. These will probably already be inside the overridden methods within your state interface implementers.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.