Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Software design: rotate between process modes [closed]

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.

like image 340
tytk Avatar asked Sep 05 '26 01:09

tytk


1 Answers

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.

like image 53
ketan vijayvargiya Avatar answered Sep 09 '26 05:09

ketan vijayvargiya



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!