Using the traditional definition of state machines, can state machine records be in multiple states at the same time? For example, if I have a User
model, can users be in both a subscriber
and in a promotional_period
state at the same time?
Note, I am not asking if it makes sense to do this, my question is - is it possible with state machines.
No. State machines have one state at a time. A combination state could be done with another state, like subscriber_and_promotional_period .
It consists of two states, Off and On. On is the initial state here; it is activated when the state machine is executed. The arrows between the states denote the possible state transitions. They define for which input a state change occurs.
A state machine is a mathematical model of computation. It's an abstract concept whereby the machine can have different states, but at a given time fulfills only one of them. There are different types of state machines.
A state is a description of the status of a system that is waiting to execute a transition. A state machine is also a visual depiction of such an abstract machine.
All the answers saying "no" are only correct if you are assuming the "typical" type of finite state machines (FSMs) known as deterministic finite automata (DFAs), which can only have a single active state at any given time.
However, this is not the only type of FSMs, and there is no good reason to restrict yourself to this type of mechanism in all cases. There are also nondeterministic finite automata (NFAs), which can be in any number of states simultaneously.
This isn't just academic, or even really about parsing (as the wikipedia links might imply): NFAs are actually quite simple and incredibly useful and are used in practice all over the place in both hardware and software implementations.
Basically, to design an NFA, you do it just like a DFA, but instead of having a "current state" and using the inputs to compute a "next state", you have a "current state set" and use the inputs to compute a "next state set". In hardware (e.g. FPGAs implemented in VHDL) this can be done literally simultaneously. In (single-threaded) software, this is typically done by just iterating through the current states in each "step" of the machine.
No. State machines have one state at a time.
A combination state could be done with another state, like subscriber_and_promotional_period
. This is the usual way to do it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With