The tag has no wiki summary.

learn more… | top users | synonyms

17
votes
10answers
4k views

State machines vs threads

Alan Cox once said "A Computer is a state machine. Threads are for people who can't program state machines". Since asking Alan directly is not an option for humble me, I'd rather ask here: how does ...
12
votes
10answers
14k views

Examples of Finite State Machines [closed]

I'm looking for good examples of finite state machines, language isn't particularly important, just good examples. Code implementations are useful (generalized pseudo-code), but it's also very useful ...
12
votes
4answers
432 views

Conceptually, how does one make a rules/constraints (not graphics/physics) engine for a game

I want to make a simple game similar to the choose-your-own-adventure books. The player is presented with a narrative text and gets to choose his action from a list of possibilities. This, in turn, ...
11
votes
5answers
3k views

Are exceptions as control flow considered a serious antipattern? If so, Why?

Back in the late 90's I worked quite a bit with a code base that used exceptions as flow control. It implemented a finite state machine to drive telephony applications. Lately I am reminded of those ...
9
votes
4answers
438 views

How can a child state machine relinquish control back to the parent state machine?

My top level state machine has some states and edges. I will call this the parent state machine. A ----> B ----> C Any state within the parent state machine can be a state machine too. I will ...
8
votes
4answers
1k views

Can an object oriented program be seen as a Finite State Machine?

This might be a philosophical/fundamental question, but I just want to clarify it. In my understanding a Finite State Machine is a way of modeling a system in which the system's output will not only ...
7
votes
6answers
764 views

How to recover from finite-state-machine breakdown?

My question may seems very scientific but I think it's a common problem and seasoned developers and programmers hopefully will have some advice to avoid the problem I mention in title. Btw., what I ...
7
votes
4answers
353 views

Definition of “state”

What is a good way to define "state", as in state variable or state machine, to a new (previously non) programmer? What are some good ways to explain why this concept is useful for writing software? ...
4
votes
2answers
250 views

Good ways to jump to a particular state in a yielding stateful function?

I'm working on some embedded code using C. Various pieces of functionality need non-blocking stateful functions, which are mostly implemented using a switch on various states. For example, a modem ...
4
votes
1answer
623 views

Passing data between concrete states?

I have a state machine pattern implementation that's pretty straightforward, but I've got a design problem I don't know an elegant solution to. Here's some partly pseudo code to illustrate. class ...
4
votes
1answer
57 views

How to Recover from Inconsistent Job State without Database Polling

I'm working on scaling an application which is currently polling a mySQL database to send async jobs to a background processing system. A state machine is being used to keep track of the entities ...
3
votes
3answers
3k views

Advantages/Disadvantages of NFA over DFA and vice versa

What are the relative pro's and con's of both DFA's and NFA's when compared to each other? I know that DFA's are easier to implement than NFA's and that NFA's are slower to arrive at the accept state ...
3
votes
1answer
580 views

Constructing a Deterministic Finite State Automaton for a given Regex

I have a couple of exam questions for my compilers class and wanted to check if my solutions are correct. The first question is: Consider a language in which numbers start with an optional minus ...
3
votes
2answers
266 views

How do I reuse a state machine in a slightly different way?

Problem I have a big state machine. The design requirements of the project have changed such that I need to re-use this state machine in another place. All the states remain the same in this new ...
2
votes
1answer
203 views

Is a finite state machine an appropriate solution for this situation?

I was writing some test code as an example where I had a washing machine class. It has a door state that should be open or closed, and also a running state, either on or off. I want to prevent the ...
2
votes
1answer
144 views

Why does F. Wagner consider “NOT (AI_LARGER_THAN_8.1)” to be ambiguous?

In his article on Virtual Environments (a part of his VFSM specification method) Ferdinand Wagner describes some new ways of thinking about Boolean Algebra as a software design tool. On page 4 of ...
2
votes
1answer
187 views

Application protocols and state machines: designing a complicated server

I'm designing and prototyping a server that has the following characteristics: during the daemon's initialization it spawns nine "manager" servers, each of which solves one part of the overall ...
2
votes
2answers
715 views

How to present asynchronous state change in chart or diagram?

I started to study about state transition chart. As I see, it assumes all state transition is done instantly with no time consuming. But in most of my case, I'm heavily depending on asynchronous I/O, ...
2
votes
2answers
194 views

Constructs for wrapping a hardware state machine

I am using a piece of hardware with a well defined C API. The hardware is stateful, with the relevant API calls needing to be in the correct order for the hardware to work properly. The API calls ...
2
votes
2answers
299 views

Communication between state machines with hidden transitions

The question emerged for me in embedded programming but I think it can be applied to quite a number of general networking situations e.g. when a communication partner fails. Assume we have an ...
2
votes
2answers
707 views

Visualize flowchart diagram with multiple end symbols

I am looking for a standardize way to visualize the following hierarchical logic: The state of the thread is represented by the answers to the hierarchical set of question You can read this listing ...
1
vote
1answer
149 views

Can all business logic be decomposed as a (declarative) state diagram on simple crud operations and conditionals?

This seems an extreme question probably but I'm wondering anyhow: Can all business logic be decomposed as a (declarative) state diagram on simple crud operations and conditionals? Already a lot of ...
1
vote
2answers
217 views

Can the Turing machine be classified?

Can the Turing machine be classified e.g. as a Mealy machine? Why not? Can a Turing machine be input to another Turing machine without complication like halting problems? Thanks
1
vote
2answers
369 views

Dependency injection with Finite State Machines and the Interface Segregation Principle

I am trying to figure out what is the best way to setup a FSM and also keep my interfaces clean and use an IOC container to use DI. Let's just visit the Head First design pattern textbook example of ...
1
vote
1answer
112 views

Converting a DFA to an NFA

I have an assignment to convert various language descriptions into NFAs and DFAs. Having graduated with my CompSci B.S. years ago and not touching the topic until my M.S. program, I am racking my ...
1
vote
1answer
396 views

How to Implement a Parallel Workflow

I'm trying to implement a parallel split task using a workflow system. I'm using .NET but my process is very simple and I don't want to use WF or anything heavy like that. I've tried using Stateless. ...
1
vote
1answer
205 views

How do you diagram global or shared state?

Say you're building an FSM for something like a game and you've got states like: MainMenu Options SinglePlayer MultiPlayer Your state diagram might look something like this: Now say you have a ...
1
vote
0answers
69 views

State Pattern Code for embedded device - Dependency Injection of Device Objects in Context and State Classes

I'm wrestling with some code and I think I've finally gotten some state pattern code working with my events. I've got a simplified system that will work like this: This is my first go with State ...
0
votes
1answer
631 views

Good example of a State Machine / State Pattern based Workflow Engine?

I am looking to implement a workflow engine using the State pattern but I cannot find a good example of this. Does anyone know of a good resource that shows building a workflow engine that utilizes ...
0
votes
0answers
96 views

Using a Finite State Machine for access management?

My intranet site uses LDAP and Active Directory to authenticate users. There are 2 kinds of Users: Managers and Employees. They are differentiated by having membership in a particular AD group. In an ...