0
FSM.NET
A simple "stateless" finite-state
machine library for .NET.
Bill Sorensen
@BillSorensen
bill@truewill.net http://w...
1
What is it?
 Open-source .NET library
 “A finite-state machine (FSM) … is a mathematical model of
computation used to ...
2
What is it? (continued)
 Domain-specific language (DSL)
 Text tables can be provided by callers, loaded from a data st...
3
Why would I need it?
 You’re trying to solve a problem that looks like a state machine.
“I have that horrible feeling w...
4
Why would I not need it?
 You want to associate actions or guards (behavior/code) with
transitions or with entering/exi...
5
Demo time!
https://github.com/TrueWill/FSM.NET
https://github.com/TrueWill/FSM.NET/tree/master/Samples
6
Why is FSM.NET written in F#?
 Fewer bugs
 Easier to verify correctness
 Immutable by default
 Less code – let’s see...
7
Other options (in no particular order)
 http://smc.sourceforge.net/
 https://github.com/phatboyg/Automatonymous
 http...
8
How can I get it?
https://www.nuget.org/packages/FSM.NET/
https://github.com/TrueWill/FSM.NET
GitHub
Upcoming SlideShare
Loading in...5
×

FSM.NET presentation

279

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
279
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "FSM.NET presentation"

  1. 1. FSM.NET A simple "stateless" finite-state machine library for .NET. Bill Sorensen @BillSorensen bill@truewill.net http://www.truewill.net/ Integrated DNA Technologies
  2. 2. 1 What is it?  Open-source .NET library  “A finite-state machine (FSM) … is a mathematical model of computation used to design both computer programs and sequential logic circuits. It is conceived as an abstract machine that can be in one of a finite number of states. The machine is in only one state at a time; the state it is in at any given time is called the current state. It can change from one state to another when initiated by a triggering event or condition; this is called a transition. A particular FSM is defined by a list of its states, and the triggering condition for each transition.” – Wikipedia
  3. 3. 2 What is it? (continued)  Domain-specific language (DSL)  Text tables can be provided by callers, loaded from a data store, stored in configuration – whatever works for you  Purely functional  Given the same arguments, every function always returns the same values  No side effects  Great for web services (inherently stateless)  Thread safe (unless I goofed) # Turnstile Locked | coin | Unlocked Unlocked | coin | Unlocked Unlocked | pass | Locked Initial state (first line) CurrentState|triggeringEvent|NewState
  4. 4. 3 Why would I need it?  You’re trying to solve a problem that looks like a state machine. “I have that horrible feeling when I know that almost the only thing I can say is that you should use a State Machine when the behavior you’re specifying feels like a State Machine – that is, when you have a sense of movement, triggered by events, from state to state. In many ways, the best way to see if a State Machine is appropriate is to try sketching one on paper and, if it fits well, to try it in action.” – Martin Fowler, Domain-Specific Languages
  5. 5. 4 Why would I not need it?  You want to associate actions or guards (behavior/code) with transitions or with entering/exiting states.  FSM.NET machines are designed to be self-contained, without requiring binary references to custom code.  FSM.NET machines are designed to be deserialized from text.  Custom code actions could be added through a wrapper (web service, etc.).  You want to embed a state machine in a non-.NET application.  FSM.NET can be used through a web service, though.
  6. 6. 5 Demo time! https://github.com/TrueWill/FSM.NET https://github.com/TrueWill/FSM.NET/tree/master/Samples
  7. 7. 6 Why is FSM.NET written in F#?  Fewer bugs  Easier to verify correctness  Immutable by default  Less code – let’s see!  Easier to write thread-safe code  Interop with other .NET libraries  Fun! 
  8. 8. 7 Other options (in no particular order)  http://smc.sourceforge.net/  https://github.com/phatboyg/Automatonymous  http://code.google.com/p/bbvcommon/wiki/StateMachine  https://code.google.com/p/stateless/  … and many more Don’t reinvent the wheel! (Like I did…) (Caveat: I have not evaluated all of the above options.) // Stateless example using enums var turnstile = new StateMachine<States, Events>(States.Locked); turnstile.Configure(States.Locked).Permit(Events.Coin, States.Unlocked); turnstile.Configure(States.Unlocked).Permit(Events.Pass, States.Locked); turnstile.OnTransitioned(x => Console.WriteLine(x.Trigger)); turnstile.Fire(Events.Coin); // mutates Console.WriteLine(turnstile.State);
  9. 9. 8 How can I get it? https://www.nuget.org/packages/FSM.NET/ https://github.com/TrueWill/FSM.NET GitHub
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×