Pregunta

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.

¿Fue útil?

Solución

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).

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top