Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

State Machine Frameworks for .NET

Tags:

We have a system at my work that is basically a message-driven state machine. It takes in a variety of types of messages, looks up some context/state based on the message, then decides what to do, based on the message and the current state. Normally the result is a message being sent out of the system.

Are there any good open-source frameworks for implementing a state machine in .NET? I've looked into the latest release of Windows Workflow, and it seems like it would be a good option; however, I have some concerns about the default persistence mechanisms (we need to report off the state transition data), testability, and the fact that the WF team is re-architecting the framework as we speak (supposedly).

Instead of WF, I'm thinking of trying to implement a plain-old GoF "State" pattern, and using Spring.NET to wire everything together. Is there anything out there that already does this, or something similar?

like image 647
Andy White Avatar asked Mar 10 '09 21:03

Andy White


People also ask

What is state machine framework?

The State Machine framework provides classes for creating and executing state graphs. The concepts and notation are based on those from Harel's Statecharts: A visual formalism for complex systems, which is also the basis of UML state diagrams.

What is stateless state machine?

"Stateless" is a simple library for creating state machines in C# code. It's recently been updated to support . NET Core 1.0. They achieved this not by targeting .

What is the difference between state machine and workflow?

In general, the major difference between a workflow engine and a state machine lies in focus. In a workflow engine, transition to the next step occurs when a previous action is completed, whilst a state machine needs an external event that will cause branching to the next activity.


1 Answers

Depending on your exact requirements you might find the State Machine Compiler is sufficient for implementing the GoF "State" pattern. It can generate C# as well as dot which can be transformed into several image formats using Graphviz. I've used it on a previous project and found it sufficient for generating a 'simple' state machine. I hope this helps.

like image 163
Bas Bossink Avatar answered Oct 22 '22 11:10

Bas Bossink