I'm designing a piece of software that is a long-running process. During its lifecycle it needs to rotate between a variety of modes or activities based on the state of the system. For example, when it starts up it will perform activity X in a loop until condition A happens, at which point it will perform activity Y until condition B happens, and then it will go back to performing X, etc. There may be an arbitrary number of different modes to rotate through.
Is there an established pattern for software that follows this type of cycle? I looked up Event Loop but that is more for asynchronous handling requests that come in from an external process. I'm looking for something that will cycle through a variety of modes in a predictable manner.
As I understand, you essentially want a state machine, that transitions from one state to another based on some external property.
State design pattern would be an appropriate fit for it- do check it out.
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