W3C home > Mailing lists > Public > www-voice@w3.org > July to September 2011

State activation before onentry

From: Sebastian Feuerstack <Sebastian@Feuerstack.org>
Date: Tue, 20 Sep 2011 11:49:15 -0300
Message-ID: <4E78A7EB.6080708@Feuerstack.org>
To: www-voice@w3.org
Hi there,

i am interested to learn about the reason why a target state of a 
transition is activated before it is entered by onentry?

I found in the procedure "enterStates" that the algorithm first
adds the state (configuration.add(s)) and then calls

"for content in s.onentry: executeContent(content)"

On the wikipedia page about UML state machines they mentioned in the 
subsection about entry and exit actions:

http://en.wikipedia.org/wiki/UML_state_machine#Entry_and_exit_actions

starting from the second paragraph that:

"The value of entry and exit actions is that they provide means for 
guaranteed initialization and cleanup, very much like class constructors 
and destructors in Object-oriented programming"

I am using state machines to describe the behavior of components
for others to observe.

Unfortunately i cannot wait for a certain state gets activated to 
trigger an action, because important initializations for the state in 
onentry are executed thereafter.

This is different from Object-oriented programming where one can create
an object with Object.new(), which instantiates it and calls the 
constructor so that it is guaranteed that the new object has been 
initialized.

So far i have figured out three options to solve this for me without 
modifying the scxml algorithm, which are not very elegant.

1. I could add the initialization action to every transition to a state
2. I could introduce artificial superstates and use their onentry to 
initialize their nested states.
3. I could add a default invoke for every state to inform others about 
that the state is activated and has been successfully entered.

Even if it seems to me that alternative 3 is the expected way of 
implementation conforming to SCXML, i am very interested if there is any 
special reason why a target state of a transition is activated before it 
is entered by onentry.

Thanks,
Sebastian
Received on Wednesday, 21 September 2011 15:59:48 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 21 September 2011 16:00:11 GMT