multiple triggered events from a composite state

113 Views Asked by At

I'm designing an application that may check the user accout balance, I've set an FSM for the application and I made a composite state for this.

enter image description here

I have some questions:

  1. Is this right to set two arrow for the tranision from this composite state?

  2. The two tranision are issued from creditAccountCheck but I didn't set the arrows from this state, is this right?

  3. Feel free to give me any other comment.

1

There are 1 best solutions below

0
On BEST ANSWER
  1. No problem there, the label next to the lines is a trigger, so once one of those events occurred (has money and (no) negative balance), then the appropriate transition will be triggered.

  2. This is ok, think of the composite state as an expanded view of a regular "accountCheck" state (after all, the remaining simple states probably have some sort of FSM inside them also).

Although specification permits having a transition going from within the composite shape out, I would advise against it, because it breaks conceptual boundaries.

If you want to explicitly visualize the flow, there is notation for that.

enter image description here

Both of them do essentially the same. In your case it doesn't really matter which one you choose, whether yours (where the "missing" transitions are implicit --- use common sense to decide how it will go), or those. If your states are more complex with complex branching and orthogonal states you may need to use more complex notation.

Finally, "hasMoneyAndNoNegativeBalance" and "hasMoneyAndNegativeBalance" are little bit redundant. You will always have money in this stage, otherwise the transition "HasMoney" wouldn't have been taken, so "negativeBalance" and "positiveBalance" should be sufficient (and easier to read).