2

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.

Mahmoud Emam
  • 1,499
  • 4
  • 20
  • 37
  • 1
    State machines are not my main expertise but shouldn't you write the `has...` labels as guards with square brackets around? – qwerty_so Nov 19 '15 at 13:05
  • without the brackets it's a trigger, not a guard https://stackoverflow.com/questions/29993065/transitions-in-uml-state-charts-better-to-use-triggers-or-guards ; but I would agree that guard may be more appropriate here – Peter Uhnak Nov 19 '15 at 13:47

1 Answers1

3
  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).

Peter Uhnak
  • 9,617
  • 5
  • 38
  • 51