1
votes

The hierarchical representation of finite state machines in UML 2.0 gives great information compression so you don't have to describe all possible state combinations. UML also provides so called orthogonal states that is they aren't mutually exclusive. And as far as I undertand this idea, if an object produces some activity in these states in response to the same event, activities corresponding to each state should simply be combined. The question arose while working on reverse engineering UML State Machine Diagrams from legacy C++ code. The refined C++ code and UML diagram are given:

void CSomeClass::somePublicMethod()
{
    if (false == m_A)
    {
        return;
        }

    if (true == m_B)
    {
        m_C = otherMethodWithSideEffects();
    }

    if (false == m_C)
    {
        // some logic with side effects and state transitions
        return;
    }

    // other complex logic with side effects and state transitions
}

UML state machine diagram:

UML state machine diagram

On the one hand states B and C aren't completely independent, on the other hand the notion of concurrent states makes diagram much simpler. Can you suggest a better solution or tell me where I'm wrong?

1

1 Answers

1
votes

Do you have a real problem where a "parallel" or "non exclusive" state machine applies ?

Seems you are looking for a very theorical concept. You diagram example, doesn't show any "transitions values", looks more like standard flowchart. ( Yes, I know, state machines are specialized flowcharts )

A hierarchical state machine should have "encapsulated" or "hidden" transition values as well.

U.M.L. flowcharts also have support to represent "parallel" or "non exclusive" paths, so if you have to model that kind of case you may want to start with them, instead of state machines.

The only hierarchical state machines I have work are related to parsers, altought, I know they are also used in electrical circuits.

Good Luck.