0

I am trying to create a simple flow from state to state (6 or 7 in all) and I decided to implement a state pattern. It felt like there was too much overhead around letting each state transition to each state when really there should be a main flow. So basically each state only really transitions to the next. This is not what the state pattern is for, correct? I understand it as a pattern for being able to transition from nearly every state to every other one (with maybe a few exceptions). What pattern should I be using for my scenario?

Thanks in advance for the help.

jaco0646
  • 15,303
  • 7
  • 59
  • 83
Tyler Smith
  • 1,269
  • 1
  • 12
  • 24

1 Answers1

1

State machines enable transitions from one state to specific other states, depending on the inputs. There is no requirement that every state can be reached directly from every other state.

As ryadavilli wrote in his comment, what you have is a workflow, which is a specific type of state machine where you can only go from one state to the next.

Workflows are usually used for finite processes (e.g. a series of actions), whereas state machines are usually used for infinite processes (e.g. wait for message, identify type, process, back to wait for message).

Danny Varod
  • 17,324
  • 5
  • 69
  • 111
  • I am having a little trouble finding more information about this due to the ambiguity of the word workflow. I keep getting sites about drawing up flowcharts of state machines. Can you suggest some reading or examples on the subject? – Tyler Smith Dec 04 '12 at 16:42
  • 1
    Check out WF (Windows Workflow Foundation) for an about of the box .NET example. – Danny Varod Dec 04 '12 at 18:19