SlideShare una empresa de Scribd logo
1 de 9
FSM.NET
A simple "stateless" finite-state
machine library for .NET.
Bill Sorensen
@BillSorensen
bill@truewill.net http://www.truewill.net/
Integrated DNA Technologies
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
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
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
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.
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!
 Easier to write thread-safe code
 Interop with other .NET libraries
 Fun! 
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);
8
How can I get it?
https://www.nuget.org/packages/FSM.NET/
https://github.com/TrueWill/FSM.NET
GitHub

Más contenido relacionado

Similar a FSM.NET presentation

Freedomotic v1.5 whitepaper
Freedomotic v1.5 whitepaperFreedomotic v1.5 whitepaper
Freedomotic v1.5 whitepaperfreedomotic
 
Modeling of reactive system with finite automata
Modeling of reactive system with finite automataModeling of reactive system with finite automata
Modeling of reactive system with finite automataZarnigar Altaf
 
Dvorkin: Software Defined Datacenter Presentation #SDDC14
Dvorkin: Software Defined Datacenter Presentation #SDDC14Dvorkin: Software Defined Datacenter Presentation #SDDC14
Dvorkin: Software Defined Datacenter Presentation #SDDC14Mike Dvorkin
 
ReDoS - Regular Expession Denial of Service
ReDoS - Regular Expession Denial of ServiceReDoS - Regular Expession Denial of Service
ReDoS - Regular Expession Denial of ServiceFrancesco Lacerenza
 
Automation Techniques In Documentation
Automation Techniques In DocumentationAutomation Techniques In Documentation
Automation Techniques In DocumentationSujith Mallath
 
Metasploit - Basic and Android Demo
Metasploit  - Basic and Android DemoMetasploit  - Basic and Android Demo
Metasploit - Basic and Android DemoArpit Agarwal
 
Comparing DOM XSS Tools On Real World Bug
Comparing DOM XSS Tools On Real World BugComparing DOM XSS Tools On Real World Bug
Comparing DOM XSS Tools On Real World BugStefano Di Paola
 
Event-driven Infrastructure - Mike Place, SaltStack - DevOpsDays Tel Aviv 2016
Event-driven Infrastructure - Mike Place, SaltStack - DevOpsDays Tel Aviv 2016Event-driven Infrastructure - Mike Place, SaltStack - DevOpsDays Tel Aviv 2016
Event-driven Infrastructure - Mike Place, SaltStack - DevOpsDays Tel Aviv 2016DevOpsDays Tel Aviv
 
You are to simulate a dispatcher using a priority queue system.New.pdf
You are to simulate a dispatcher using a priority queue system.New.pdfYou are to simulate a dispatcher using a priority queue system.New.pdf
You are to simulate a dispatcher using a priority queue system.New.pdfgardenvarelianand
 
Chapter 1 introduction to .net
Chapter 1 introduction to .netChapter 1 introduction to .net
Chapter 1 introduction to .netRahul Bhoge
 
Azure Service Fabric and the Actor Model: when did we forget Object Orientation?
Azure Service Fabric and the Actor Model: when did we forget Object Orientation?Azure Service Fabric and the Actor Model: when did we forget Object Orientation?
Azure Service Fabric and the Actor Model: when did we forget Object Orientation?João Pedro Martins
 
[null]Metapwn - Pwn at a puff by Prajwal Panchmahalkar
[null]Metapwn - Pwn at a puff by Prajwal Panchmahalkar[null]Metapwn - Pwn at a puff by Prajwal Panchmahalkar
[null]Metapwn - Pwn at a puff by Prajwal PanchmahalkarPrajwal Panchmahalkar
 
WPF Windows Presentation Foundation A detailed overview Version1.2
WPF Windows Presentation Foundation A detailed overview Version1.2WPF Windows Presentation Foundation A detailed overview Version1.2
WPF Windows Presentation Foundation A detailed overview Version1.2Shahzad
 
Real Time Operating System
Real Time Operating SystemReal Time Operating System
Real Time Operating SystemSharad Pandey
 
Top 20 Asp.net interview Question and answers
Top 20 Asp.net interview Question and answersTop 20 Asp.net interview Question and answers
Top 20 Asp.net interview Question and answersw3asp dotnet
 

Similar a FSM.NET presentation (20)

Freedomotic v1.5 whitepaper
Freedomotic v1.5 whitepaperFreedomotic v1.5 whitepaper
Freedomotic v1.5 whitepaper
 
Modeling of reactive system with finite automata
Modeling of reactive system with finite automataModeling of reactive system with finite automata
Modeling of reactive system with finite automata
 
Dvorkin: Software Defined Datacenter Presentation #SDDC14
Dvorkin: Software Defined Datacenter Presentation #SDDC14Dvorkin: Software Defined Datacenter Presentation #SDDC14
Dvorkin: Software Defined Datacenter Presentation #SDDC14
 
Modern Embedded Software
Modern Embedded SoftwareModern Embedded Software
Modern Embedded Software
 
ReDoS - Regular Expession Denial of Service
ReDoS - Regular Expession Denial of ServiceReDoS - Regular Expession Denial of Service
ReDoS - Regular Expession Denial of Service
 
Automation Techniques In Documentation
Automation Techniques In DocumentationAutomation Techniques In Documentation
Automation Techniques In Documentation
 
Metasploit - Basic and Android Demo
Metasploit  - Basic and Android DemoMetasploit  - Basic and Android Demo
Metasploit - Basic and Android Demo
 
dot NET Framework
dot NET Frameworkdot NET Framework
dot NET Framework
 
Comparing DOM XSS Tools On Real World Bug
Comparing DOM XSS Tools On Real World BugComparing DOM XSS Tools On Real World Bug
Comparing DOM XSS Tools On Real World Bug
 
Event-driven Infrastructure - Mike Place, SaltStack - DevOpsDays Tel Aviv 2016
Event-driven Infrastructure - Mike Place, SaltStack - DevOpsDays Tel Aviv 2016Event-driven Infrastructure - Mike Place, SaltStack - DevOpsDays Tel Aviv 2016
Event-driven Infrastructure - Mike Place, SaltStack - DevOpsDays Tel Aviv 2016
 
.Netframework
.Netframework.Netframework
.Netframework
 
You are to simulate a dispatcher using a priority queue system.New.pdf
You are to simulate a dispatcher using a priority queue system.New.pdfYou are to simulate a dispatcher using a priority queue system.New.pdf
You are to simulate a dispatcher using a priority queue system.New.pdf
 
Chapter 1 introduction to .net
Chapter 1 introduction to .netChapter 1 introduction to .net
Chapter 1 introduction to .net
 
Azure Service Fabric and the Actor Model: when did we forget Object Orientation?
Azure Service Fabric and the Actor Model: when did we forget Object Orientation?Azure Service Fabric and the Actor Model: when did we forget Object Orientation?
Azure Service Fabric and the Actor Model: when did we forget Object Orientation?
 
Metapwn
MetapwnMetapwn
Metapwn
 
[null]Metapwn - Pwn at a puff by Prajwal Panchmahalkar
[null]Metapwn - Pwn at a puff by Prajwal Panchmahalkar[null]Metapwn - Pwn at a puff by Prajwal Panchmahalkar
[null]Metapwn - Pwn at a puff by Prajwal Panchmahalkar
 
The JSON architecture
The JSON architectureThe JSON architecture
The JSON architecture
 
WPF Windows Presentation Foundation A detailed overview Version1.2
WPF Windows Presentation Foundation A detailed overview Version1.2WPF Windows Presentation Foundation A detailed overview Version1.2
WPF Windows Presentation Foundation A detailed overview Version1.2
 
Real Time Operating System
Real Time Operating SystemReal Time Operating System
Real Time Operating System
 
Top 20 Asp.net interview Question and answers
Top 20 Asp.net interview Question and answersTop 20 Asp.net interview Question and answers
Top 20 Asp.net interview Question and answers
 

Último

Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 

Último (20)

Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 

FSM.NET presentation

  • 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. 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. 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. 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. 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.
  • 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. 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. 8 How can I get it? https://www.nuget.org/packages/FSM.NET/ https://github.com/TrueWill/FSM.NET GitHub