I'm making a Windows Forms app:
- It is client-server. Authorization, then load some data from server, then send back some statistics from time to time.
- You should go through a bootstrapping procedure, then it starts computations (a separate process). Then you can pause it anytime, probably scheduling it to start computing again, or quit it completely.
My code is full of checks like "Is this data available? Load it from the server." or "Is this data available? Prompt it from the user." or "Is a start is scheduled? Cancel it, start now.".
I feel like my app is a state machine. It's like it has a state like this: AUTH
/ WORKING
/ PAUSED
/ PAUSED_SCHEDULED
/ SHOWING_ERROR_MSG
plus a bunch of data availability flags. My code initiates transitions from state to state and performs them, is basically tries to keep the app in a correct state. The code is messy with data availability checks, long bootstrapping in every single method, tons of fail-retry code everywhere.
Are there any design patterns and frameworks I can use? Is there something good and widely used? Are there any caveats I overlook? It feels like my code could be a level more high-level.