restumlstate-diagram

How to model this process using a state diagram?


I am modelling a process using an UML state diagram. Here is some pseudo-code that determines the current state:

function getAccountState(customer) {

    if (authorizationRequired(customer)) {
        return State.AUTHORIZATION_REQUIRED
    }

    if (updateRequired(customer)) {
        return State.UPDATE_REQUIRED
    }

    return State.DRAFT
}

The closest I got was this diagram: State diagram

However, I think it is somewhat strange that each transition is contained twice. The order matters though which means, the authorization-check should always come first.

How would one model this process?

EDIT:

The background behind this process is a REST service. The account is modeled as a resource and can go through various states. Any time the resource is requested, the service performs the checks in the order described by the pseudo code above to generate an according representation. Depending on the answer, it includes either:

The code above is just an example though. The service could also utilize a database field storing the "state", although this is an anti-pattern isn't? It is more feasible to "derive" the current state by applying the business rules on the stored data instead of (redundantly) storing the state in a separate field. That is what the pseudo code should indicate.


Solution

  • According to your edit, I'd come up with the following approach:

    enter image description here

    You will reach the Draft state through (optional) authorization and updating. If they fail, the state machine is reset.