Activity Diagram
An activity diagram is a graphical representation of behavior depicted by a sequence of steps. It can be used to model any business or technical activity including business and technical processes and also computer algorithms. Basically, it serves the same purpose as the good old flowchart but with much richer semantics.
Elements
- Activity
- Activity represents a behavior
- Action
- Action represents a single step within the activity
- Actions can be further specified by a behaviour. For instance, the
Action2
indicates that its behaviour is described within the separate activity.
- Swim lane
- Swim lanes group activities performed by the same actor or system. This is useful for modeling processes and workflows to indicate who actually does a particular step.
- Control flow
- Connector that shows the flow of the control between the steps
- Decision node/Merge node
- A decision node accepts tokens on an incoming edge and presents them to multiple outgoing edges
- Which of the edges is actually traversed depends on the evaluation of the guards on the outgoing edges
- A merge node merges all incoming tokens into a single outgoing token. In the example above, the flow goes to the Final Node when any of the control flows reach the Merge Node. Without the Merge Node, the flow would wait until both flows reach the Final Node.
- Fork/Join
- A fork node is a control node that splits a flow into multiple concurrent flows. Both actions in the picture will be executed.
- A join node is a control node that synchronizes multiple flows. In other words, the flow waits until all concurrent flows reach the join node.
- Event
- Event represents an external trigger such as an incoming message or time event indicating that the control flow starts at a specific time
- For the time events, a clock symbol is usually used
Modeling
The core function of the activity diagram is to visualize the behavior, yet it could also include other useful information, such as what output a particular step produces, what function it calls or how it changes the entity state.
1. Output
If the activity represents a calculation that generates data as output, it is convenient to describe the format of the result. The following example shows the format of the calculated commission by connecting the activity to the generated data object using a create connector.
2. Function or Service Call
Since actions are the lowest-level atomic elements, they are often used to model invocation of a concrete function or service (in the UML terminology an operation call). The model below shows two possible ways of modeling the service call: using a dependency relationship and without it.
3. Condition
The flow of activities and actions is controlled by guards, which specify conditions for selecting a particular branch. Very often, the condition is represented by a general business rule which is stored in a business rules repository, so it is sufficient to reference it instead of duplicating it.
4. States
Sometimes it is useful to indicate that the activity changes the state of the entity. The following flow depicts the order processing workflow and shows how the process changes the order state.
5. System or Role
Indicating who (party) or what (system) performs the particular step is indicated using swimlanes. Additionally, if the swimlane classifier points to the system in the repository, any changes to the system automatically propagate to the corresponding swimlane in all diagrams.
Note: In the Part III we are going to provide more detailed information concerning the implementation of the practices mentioned above in the real CASE tool.