Hi ersteslicht,
The pattern of EA FSM code generation uses, is to introduce an event driven loop to the class containing the state machine in the model.
It's exactly what GoF State pattern teaches us to avoid, because it'll become pretty messy and hard to maintain code as it evolves, when more states, transitions or events (triggers) need to be added.
Event driven loop has it's advantages also, if you need to work with very limited devices or really really tough performance requirements.
It's possible to adjust the EA code generation templates to achieve different renderings of state machines in code. But this has currently certain drawbacks also:
- Code (re-)engineering of the generated code doesn't synchronize the SM model (that's also true for the default templates)
- If you're generating classes instead of state functions they'll still all be placed in the same file(s)
The currently most promising attempt to do SM code generation with EA seems for me, to use it for a FSM DSL that provides an appropriate compiler for your target language (as SMC for example). That's also discussed in another thread in the forum (see
http://www.sparxsystems.com/cgi-bin/yabb/YaBB.cgi?num=1256588736).
I have also a proposal for a C++ template class library that purposes to help for translation from UML state diagrams to GoF State pattern like constructs. But I'm still far from providing EA code generation templates for it. For this I still think, I would need to be able to do a model transformation from state machine to class model (which the State pattern also does). But EA doesn't provide EASL templates for model transformation.
@all_sparxians_reading_here:
Why don't you guys, is it that much difference? Recently one of you confirmed that it's all the same, for code or transformation intermediate language.
So, if you're interested in my draft documentation for the C++ lib, leave your email in the message box of this account (the other's in my workplace), and I'll hand it over.
WBR
Günther