MathewWi / umple

Automatically exported from code.google.com/p/umple
0 stars 0 forks source link

When reaching a Final state, exit action of current state must be called before object deletion #252

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Consider the following state machine example:

class FinalState {
  stateMachine {
    L1 {
      L2 {
        // this exit action must be called before deleting the object.
        exit/{exiting L2}
        T -> Final;  
}  }  }  }

If the state machine is in L2 and T occurs, the object will be deleted because 
of reaching the Final state.

The Problem:
The exit action of L2 and L1 are not called before deleting the object.

Correct behavior:
When reaching a Final state from an inner state, all exit actions of the inner 
state and parent states must be called before the object is deleted.

DISCUSSION:
Alternatively, the exit action of the current state is called. Exit actions of 
parent states are ignored.

Original issue reported on code.google.com by oob...@gmail.com on 31 Dec 2011 at 7:46

GoogleCodeExporter commented 9 years ago
It does not make sense to call exit actions of parent states for two reasons:

1. According to the latest UML specs (2.4 beta 2), reaching a final state 
implies the whole state machine is completed.  There is no mentioning in the 
specs about being in an inner state and calling exit actions of parent states.

2. The final state can be either inside L1 or outside of L1. If it is outside 
of L1 then it makes sense to call exit action of L1 since we are leaving that 
state. However, in Umple, we can not differentiate these two situations since 
(try to model these two situations in Umple, you will get the same model).

Therefore, whenever reaching a Final state, the exit action of the current 
state is called, but not that of any other state (even if the state happened to 
be an inner state of a parent state with an exit action.)

Original comment by oob...@gmail.com on 31 Dec 2011 at 7:53

GoogleCodeExporter commented 9 years ago
It seems clear to me that it would be best to call the exit actions. 

Just because there is no mention in the UML specs is not a good reason not to 
do it.

Final states are not logically in any scope (they are neither inside or outside 
L1). Transition to final is just a notation, not a special state. 

I can see an argument for calling *no* final state, but it seems utterly 
illogical to call the final state of the enclosing state only.  The most 
logical case would be to call all the exit actions. After all, exit actions are 
supposed to be 'clean up'. Think of the legitimate uses of exit actions.

Original comment by TimothyCLethbridge on 2 Jan 2012 at 2:35

GoogleCodeExporter commented 9 years ago

Original comment by TimothyCLethbridge on 15 Feb 2012 at 5:43

GoogleCodeExporter commented 9 years ago

Original comment by TimothyCLethbridge on 31 Jan 2014 at 6:59