Completion Event - modelint/shlaer-mellor-metamodel GitHub Wiki
The purpose of a Completion Event is to make it easy to handle conditional logic or to simplify a State Activity by splitting it across one or more Real States.
In the first use case you might have an action like this:
too hot?
initiate cooling -> : sit comfortably -> me
In the action language above we evaluate an input scalar flow named too hot
and signal one of two possible events to self. Presumably, each of these self directed events triggers a Transition to a different Real State where appropriate action is taken.
For this logic to work correctly, no arriving Interaction Event should be processed until completing our logic. So if a disable cooling
event were to be signaled from somewhere and available after we complete the State Activity, we would first resolve the conditional logic by selecting the self directed event and transitioning to any destination state first.
Another use case simply splits a big state into two smaller states like so:
// various actions of the first state here and then...
finshed the first part -> me
Here a number of Actions are processed and then we send a self directed event so that we can move on to the next State where we either continue with more actions or, and this is fairly common, simply land on a state where we just wait.
A distinction has historically been made in Shlaer-Mellor between the handling of self directed and non-self directed events. It has always been understood that any self directed event will be processed before any non self directed event.
But the self vs. non-self naming has let to some confusion when boundaries of the originally intended use cases are pushed to absurdity.
For example, let's say you have a State Activity that sends multiple self directed events like this:
go1 -> me
go2 -> me
go3 -> me
Here we end up dispatching multiple self directed events while in the same Real State. This will just complicate our state model logic with no benefit. In fact, there should never be more than one Completion Event pending for a given State Machine at any time.
And what does it mean to send a delayed event to self?
continue -> me @ some delay
This is certainly not in keeping with our logic completion goals.
To avoid all this nonsense, we refer to a self directed event instead as a Completion Event. All other Dispatched Events are Signaled either from and to the same instance or from some external Activity.
If a Completion Event is pending for some State Machine and another is dispatched to the same State Machine, this will result in a model execution error.
Identifiers
- ID + State Machine + Domain
Attributes
No non-referential attributes.