G+: Why do implementing FSMs give me such a …

David Coles
Why do implementing FSMs give me such a headache?

In theory, they're pretty simple: (state, event) → (new_state, output). Great for processing a series of events, but turn absolutely miserable when you have to make them interact with multiple threads or more traditional styles of programming. They really seem to like being their own little worlds where they don't have deign to interact with the rest of the world.

I'm sure there's got to be a better way to interact with them (such as using methods as your events), but it still feels clunky especially if you still want to keep them nice and data-driven. 

Abdulla Kamar
There was a really nice example of one in David Abraham's C++ Template Metaprogramming book. It's been awhile since I read it, but I remember it being quite nice.

David Coles
Thanks Abdulla. Yeah - it definitely feels like you want to hide the low-level details and leave run-time code for doing useful things at runtime. I actually quite liked the GOF example under the State pattern - using classes to define your states and polymorphism to allow transitioning between them (just changing the current "state" object).