Search code examples
umlstatediagramfsm

UML state diagrams and Moore/Mealy machines


How to model Moore and Mealy machines with UML state diagrams? Besides, how to represent outputs in those diagrams? Through Actions?


Solution

  • UML state diagrams have the characteristics of both Mealy and Moore state machines.

    To represent a pure Mealy machine, you use only actions on transitions:

    stateA -- TRIGGER [guard] / action() --> stateB
    

    To represent a pure Moore machine, you use only entry or exit actions to states, but you don't use actions on transitions:

    stateA
       entry/ actionA();
    
    stateB
       entry/ actionB();
    

    When you use both actions on transitions and entry/exit actions in states, you have a mix of Mealy and Moore machines.