querying the state of a state machine

50 views
Skip to first unread message

Rafael Chaves

unread,
Jan 11, 2013, 1:47:49 PM1/11/13
to UMLf...@googlegroups.com
This is related to a thread I started a while ago ("state as a
condition for an operation"), but not quite the same. Basically, I
modeled the status of an expense reported using a state machine (which
was easy), and then needed to allow the user to find all expenses that
have some status (say, "all approved expenses"). The problem is that
it is not possible to implement a condition such as:

this.status == Approved

because, as far as I know (and that previous thread confirmed) there
is no built-in way to refer to states in UML (no "state literals").

I ended up having to "creatively model" state literal extending some
other literal metaclass with a stereotype that allows me to reference
a state machine state (vertex).

So, the question is: can you think of a better way?

You can read more about this (including more details on the
application being developed) here:

http://abstratt.com/blog/2013/01/11/checking-the-current-state-of-a-uml-state-machine/

Your feedback here or there is much welcome.

Thanks,

Rafael

Remy Fannader

unread,
Jan 12, 2013, 3:06:44 AM1/12/13
to umlf...@googlegroups.com
Hi Rafael,
I've a limited experience with that kind of problem so I may be wrong. I thought it could be dealt with using StateChart and event-driven models, for instance with derived events signalling changing states as illustrated by the example below ?
http://caminao.wordpress.com/how-to-implement-symbolic-representations/patterns/functional-patterns/event-patterns/
Remy


--
You received this message because you are subscribed to the Google
Groups "UML Forum" group.
Public website: www.umlforum.com
To post to this group, send email to umlf...@googlegroups.com
To unsubscribe from this group, send email to
umlforum+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/umlforum?hl=en?hl=en

david reye

unread,
Jan 12, 2013, 3:42:14 AM1/12/13
to umlf...@googlegroups.com
Rafael,

There is a way to express your query in UML

You can access an object's state using oclInState which is defined for all objects.
Assuming there is a static class operation called Expense::findAllApproved(), the following says that the result is the set of Expenses which are in the Approved state.

context Expense::findAllApproved() : Set(Expense)
post: result = Expense.allInstances()->select( oclInState(Approved) )

Cheers,
David


--
You received this message because you are subscribed to the Google
Groups "UML Forum" group.
Public website: www.umlforum.com
To post to this group, send email to umlf...@googlegroups.com
To unsubscribe from this group, send email to
umlforum+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/umlforum?hl=en?hl=en

David Reye
Software Systems Consultant




Ken Lloyd

unread,
Jan 12, 2013, 9:41:17 AM1/12/13
to umlf...@googlegroups.com
UML abstractly handles preconditions and postconditions.

For a look at how to handle real-world instances of these using OCL, see:
http://www.is.informatik.uni-duisburg.de/courses/mod_ws06/skript/uml-ocl.pdf

Ken

Rafael Chaves

unread,
Jan 12, 2013, 12:33:11 PM1/12/13
to umlf...@googlegroups.com
Thanks Ken and David for your replies. Unfortunately I am not using OCL, just UML by itself, including for specifying behavior and constraints.

Cheers,

Rafael

On Sat, Jan 12, 2013 at 6:41 AM, Ken Lloyd <kal...@wattsys.com> wrote:
UML abstractly handles preconditions and postconditions.

For a look at how to handle real-world instances of these using OCL, see:
http://www.is.informatik.uni-duisburg.de/courses/mod_ws06/skript/uml-ocl.pdf
io
Ken

Rafael Chaves

unread,
Jan 12, 2013, 12:38:50 PM1/12/13
to umlf...@googlegroups.com
Hi Remy,
 
Let me know if I'm wrong, but my problem is about being able to reason on the state of objects for querying purposes, considering a frozen snapshot of the system (no events or transitions happening anywhere), so dynamics would not help.

Cheers,

Rafael
Reply all
Reply to author
Forward
0 new messages