Search code examples
umlstatechart

How do you represent an asynchronous action that can modify the program state in a statechart?


I have an action that does 2 things, first it will change the application state and second it makes a call out to a webservice. When the webservice sends it's response, it will affect the current application state.Example statechart

Lets say I have the above setup. Method1() calls the webservice and causes the state to change from A to B. After the Method1() call up to the Finish() call, the status can change from B to C, B to Success, etc..

If B changes to Success, it could also then change from Success to C.

How would I tie in the Success and Fail states when the state can be set at any point after the Method1() action?


Solution

  • I am not sure to really understood your whole issue but for designing your problem I would use events. A transition can be trigger when an event occurs so I would create an "ReceiveResponse" event and a transition between state B and the decision Node (as depicted below). This models the fact that if you state machine is in state B and receive a response the transition is triggered and will, according to the value of the response, change is status from B to Success or Fail.

    Modelio state machine

    Maybe could you describe a little more the possible transition or state possible? Is it possible for your object to be in two state at the same time?

    Hoping it helps,

    EBR