Compact state machines by George H. Mealy

In comparison with the Moore machines seen above, Mealy machines produce outputs only on transitions and not in states. This often results in state diagrams with fewer states because more logic can be put on transitions. As a Mealy machine, the ferry example looks like the following image:

Ferry example as a Mealy machine

Ferry example as a Mealy machine

States do not produce outputs anymore, but the transitions do. Whether the ferry moves northwards or southwards is now expressed by the corresponding transitions. The input event mate.sail may lead to the output ferry.moveSouthwards or ferry.moveNorthwards depending on the active state. The state machine offers an extended logic: the states Northwards and Southwards have two transitions that lead to different states depending on the input event: If the event mate.sail is raised in Northwards the output is ferry.moveSouthwards, if quay.reachedNorthernBank is raised the ferry stops. The same logic as a Moore machine would lead to additional states like the following image shows:

The ferry as an extended Moore machine

The ferry as an extended Moore machine

Be aware that both state diagrams, the Moore machine above and the Mealy one, describe exactly the same system. Indeed, automata theory states that you can always translate a Moore machine into a Mealy machine and vice versa, without losing any expressiveness.