Fork me on GitHub
#architecture
<
2018-02-20
>
drewverlee20:02:38

Has anyone read any good resources on trying to use Finite State Machines to be the top level abstraction for you system? For example, in designing a simple tic tac toe game i figure it might help to model the flow of the game using FSM. Then having the FMS drive the program. get-input -> ( ) -> interpret-input -> ( ) -> take-spot This would seem to have the advantage that it makes your system execution path more readable. But I assume if this was easy and helpful i would hear more people talk about it. Sense i hear almost no one talk about it then i assume its probably only helpful in some contexts. I’m trying to figure out what has been explored in this area. Suggestions are welcome.

fellshard20:02:26

IIRC there was a very simple game engine someone made that tried just that... I think it was presented at Strange Loop or something a couple of years back

fellshard20:02:15

If you're trying to represent your entire application's state as one giant state machine, you'll find yourself needing to decompose it into tuples of mostly-independent state, I suspect.

fellshard20:02:14

In some sense, the argument could be made that the Elm architecture is an example of treating the system as one giant state machine.

fellshard20:02:38

Update messages are essentially state transitions, with the target state being selected by the message it's passed.

fellshard20:02:31

What you're talking about seems less like a state machine, though, and more like a flow diagram....

fellshard20:02:22

More reminiscent then of 'pipes and filters'

Ivan21:02:44

Elm and redux too

Ivan21:02:55

though this is not explicitly a state machine

Ivan21:02:22

If you've looked into event sourcing architectures, people sometimes use BPM (aka business process managers) which resemble steps of processes, much like modelling a state machine

Ivan21:02:07

camunda is such an engine and can generate a graph of the process

Ivan21:02:25

and also colour-code the graph based on an execution

Ivan21:02:50

https://zeebe.io/ tries to do the same

Ivan21:02:49

Other interesting stuff on this space (state machines on top of distributed systems) would be Petri nets https://en.wikipedia.org/wiki/Petri_net implemented in TLA+

Ivan21:02:07

It is all the same underlying idea whether it is called "workflow engine" "process engine" "bpmn" "orchestration engine"

Ivan21:02:24

an abstraction over state machines

andrewhr21:02:53

Product wise, I would add AWS Step Functions to that list

john22:02:27

@drewverlee there's javalin https://github.com/hoplon/javelin which could be used to make arbitrary automata like structures

john22:02:39

If dropping down to a pure FSM, I'd think it is because you want to constrain the behavior of the game to extremely strict semantics.