Tuesday, January 6, 2009

Activity diagram expansion regions

Activity diagrams are essential to UML modeling. The represent the atomic actions in a software system, usually implemented by some method. One problem in earlier UML activity diagrams was the lack of expressiveness in modeling iterations or loops. Modeling simple looping constructs was pretty straight-forward.

Here, we have a simple command input loop that will continue retrieving user input until an exit command is issued.

This get more complicated when iterating through a set. For example.

Here, we are modeling an iteration through a set. This activity diagram is much more complex than the previous diagram. The real drawback here is that we are showing more of the looping construct here than anything else. This defeats the purpose of the UML; to visually show the problem you are trying to solve. In most cases, iterating through a set is a trivial task and is does not need to be modeled. In the example, we want to show that we are doing something to each element in the set.

Expansion regions solve this trivial looping construct problem. They are a modeling element used in activity diagrams that wrap-around all actions that take place per set element.

Since all the open source tools I use don't support this UML element (I haven't found one that does), advanced UML has a nice example of what expansion regions look like.

No comments :

Post a Comment