Linked Questions
17 questions linked to/from Is there a typical state machine implementation pattern?
3 votes
1 answer
3k views
design pattern suggestion for ussd [duplicate]
I'm using php to create a USSD page. I've done this before and it was quite the time-constrained hack-job; basically one huge file with a switch statement for all the possible states that the ...
205 votes
26 answers
107k views
C state-machine design [closed]
I am crafting a small project in mixed C and C++. I am building one small-ish state-machine at the heart of one of my worker thread. I was wondering if you gurus on SO would share your state-machine ...
19 votes
9 answers
24k views
State machines in C
What is the best way to write a state machine in C? I usually write a big switch-case statement in a for(;;), with callbacks to re-enter the state machine when an external operation is finished. Do ...
7 votes
4 answers
2k views
How can I obfuscate a test in code to prevent tampering with response processing?
I am looking for a way to obfuscate (in the object code) a test - something like what might be done to check that a license key is valid. What I am trying to prevent is someone searching through an ...
3 votes
5 answers
2k views
What's the best(when performance matters) way to implement a state machine in C#?
I came up with the following options: Using the goto statement: Start: goto Data Data: goto Finish Finish: ; using the switch statement: switch(m_state) { case State.Start: ...
0 votes
3 answers
3k views
Apache Commons SCXML State Machine Framework
I'm attempting to define a state machine for a Java application using Apache SCXML. However, I've run into a problem and I'm not sure if this is due to the SCXML framework or me doing something wrong. ...
2 votes
4 answers
964 views
Reading a string of numbers separated by commas
I'm writing a function that is supposed to read a string of numbers, separated by commas. The format of the string is as following: "1, 2, 3" The only "rule" is that the function ...
1 vote
1 answer
945 views
C share multiple enums among different files
I apologize if my terminology is not perfect, I am a self taught programmer :) My automatic machine has different moving parts, and for each one I have a C file handling its own state machine. Each C ...
1 vote
2 answers
1k views
Priority of statemachine transitions with substates
I am currently writing a generic statemachine. But I have a couple of understanding problems. Say I have a state A. A transitions to B if a condition is met. A also has a substate A1. A1 transitions ...
3 votes
2 answers
1k views
State machine with interface-separated states
In a classic version of states, each state implementing some interface. So we can pass execution to any current state class Context { private State _state; public void MethodA() { ...
1 vote
1 answer
1k views
What is a good way to implement state-machine-like transitions in FreeRTOS?
Clearly, states of a machine will be abstracted into tasks, but how are transitions controlled? The functionality I'm looking for is that only one of the state tasks is active at a time, while the ...
0 votes
3 answers
288 views
State machine coding - im stuck
I am trying to create a state machine but am a little lost. Please go easy on me, i've only been coding 4 months. Im using a pic16f18325 and coding in mplab So i think im pretty much there, i know ...
0 votes
1 answer
373 views
Logic of Dependencies: Is if/then the only/best way?
I have a sequence of N boolean values. Some of them are dependent on others. For example, if N[0] is false, all the others must also be false. If N[0] is true, then N[1] can be true or false. If N[1] ...
0 votes
2 answers
309 views
Forcing communication between threads
I am a bit of a novice with pthreads, and I was hoping someone could help with a problem I've been having. Say you have a collection of threads, all being passed the same function, which looks ...
0 votes
0 answers
289 views
Refactor deep functions calls
I work on data processing which works with layered data. The best analogy to my current work is that of network processing. Packets are layered and each layers is processed individually by a ...