Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How hard would it be to dynamically generate state machine workflows dynamically? #353

Open
bsoulier opened this issue Feb 20, 2020 · 6 comments

Comments

@bsoulier
Copy link

Hi everyone around,

My idea would be to use Sateless to build up a sort of UI that would at the end generate a State Machine workflow that I could run dynamically.

Would this be something feasible using Stateless?

@HenningNT
Copy link
Contributor

Yes, I would think that this is possible ;-)

@HenningNT
Copy link
Contributor

Sorry, that wasn't very helpful.
I've been thinking a bit about it, and I think that you could ge a bit of inspiration from this example:
https://github.com/HenningNT/ObjectsAsStates

You could use a class that has a method that accepts the state machine as an argument, and configures it according to the configuration and the class' needs.

You could use the PermitDynamic to trigger a transition to any state.
You could use Dependency Injection to find classes / states for assembling a state machine.

I once made a control system for a high voltage generator, and I made a GUI to create voltage sequences for conditioning the X-ray tubes, which was then run by another GUI.

So yes, it should be doable.

@Toxantron
Copy link

I've been thinking a bit about it, and I think that you could ge a bit of inspiration from this example:
https://github.com/HenningNT/ObjectsAsStates

That looks like the StatePattern implementation of state machines. We created a similar implementation of that pattern and are currently discussing whether to use stateless or to integrate our solution with stateless.

@HenningNT
Copy link
Contributor

@Toxantron I'm just curious what you decided on?

@Toxantron
Copy link

We will keep our implementation using base classes for a state machine, derived classes as states and methods as triggers or for state specific behavior. The last one has been really helpful to clean up components with lots of if (someState) code in our applications. Especially for larger state machines it has helped to distribute and structure state specific code better.

However I do see use cases for state less within MORYX for smaller state machines like connection handling, were our current approach sometimes feels overblown, but going back to if and switch(state) case is not an option either.

I took a second look at ObjectsAsStates, so I am unsure how our pattern would integrate with stateless. So thanks for following up and I might get back to you when we evaluate stateless within a driver or something.

@HenningNT
Copy link
Contributor

Thanks for responding.
Replacing something that is working with an unknown is always risky, so using the working solution is probably the safest approach.
But using a "proper" state machine instead of if (state) and switch(state) is an improvement. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants