Activity model is the activity diagram which expresses the sequence of steps required to form a complex process. The activity diagram displays the flow of control like the conventional flow chart but is considered as the more advance version of it.
The activity diagram is similar to the sequence diagram as we have seen in our previous content. But, unlike a sequence diagram, the activity diagram concentrates on the operations that have to be performed by the objects not on the objects.
In this section, we will be discussing the activity model in brief along with its elements and examples.
Content: Activity Model
What is Activity Model?
Activity model is a behavioral model that details the use case model and the sequence model. Generating an activity model is creating an activity diagram for a process. The activity model concentrates on the operations or activities which are nothing but the intermediate steps in a process rather than actors initiating the operation.
Activity model shows the step by step explanation of a process and also explain the flow of control within the process. Activity model is able to express the processes with a sequential flow of control as well as the concurrent flow of control.
Activity model is generally used to model the human organizations as they involve the multiple objects that perform the operation concurrently.
Activity Diagram
Activity diagram is a graphical representation of a process where you can identify the intermediate steps of the process along with the progression of steps. Activity diagram is used by the developer to understand the complex algorithm and its workflow. As the activity diagram expresses the computation by defining the steps required to execute an operation.
Like the activity diagram below shows the steps required to perform stock trading. As you can see the activity diagram of processing a stock trade starts with a step verify order and then perform multiple activities before closing the order.
It’s very easy to understand the flow of the activity diagram as everything here is precise and well described. Activity diagrams do include conditions to decide which successor activity has to be performed next. It is able to express concurrent activities as well.
Activity Diagram Notations
1. Activities
Activities are the operations that are arranged sequentially to make up a complex process. Activities are of two types one, which keeps on executing continuously until interrupted. The other kind of activity is one which terminates itself when completed.
Completion of activity indicates that an event has been completed and a new activity could be started. The flow of control from one activity to another is represented by an arrow. When the arrow showing the flow of control is unlabeled that means the second activity could not begin until the first activity gets completed.
If an activity is composed of several finer activities then it could be elaborated in a separate activity diagram. You can not expand activity in the same activity diagram as it is important to maintain balance in the activity diagram. This means in an activity diagram each activity should be at the same level of detail.
Like, the activity diagram above for stock trade processing has two activities ‘execute order’ and ‘settle trade’ both are comprised of several finer activities. But both are showing the high-level operation by hiding the underlying activities.
If you want to replace any of the activity by its detailed steps then you have to replace other activities in the activity diagram by their detailed steps. Just to maintain the balance of the activity diagram.
But detailing the steps of each activity in the single activity diagram would make your activity diagram messy. So, it is advised to elaborate the composite activities in the separate activity diagram just as the below activity diagram details the activity ‘execute order’.
2. Branches
Some activities may have more than one successor as we have in condition. If a condition results in true divert the process to a certain step or if the condition results in false divert the process to another step.
So, the activities with multiple successors must have their branches or arrows labelled. The label over the branches would indicate the condition when the following activity should begin.
When an activity with multiple successors completes, its all subsequent conditions are checked and whichever condition gets satisfied the corresponding branch indicate the next activity to perform.
In case none of the condition is getting satisfied then the system would be hanged unless interrupted by an external event. To avoid such a scenario the developer must also implement the else condition which satisfies when none of the condition is getting satisfied.
The multiple branches could emerge from a diamond and each enters to a different activity. Which branch will be followed depends upon which branch condition has satisfied.
3. Initiation and Termination
Every activity diagram has initiation and termination. Initiation of an activity diagram is indicated with a solid circle and an outgoing arrow which enter to an activity that has to be performed first.
Activation of an activity diagram brings the control to the solid circle which pass the flow of control to the activity targeted by the arrow emerging out of the solid circle.
As every starting has an ending, the termination of an activity diagram is denoted by the solid circle enclosed by a hollow circle. There can be multiple termination points in an activity diagram. An incoming arrow towards the termination point shows that the control reaches the termination point. As the control reaches the termination point it indicates activity is completed and the activity diagram ends.
4. Concurrent Activities
As we have studied above the activity diagram can lets both sequential as well as the concurrent flow of control. Performing concurrent activities means performing multiple activities at a time.
In the activity diagram containing concurrent activities changes its flow of control. For suppose an activity may transfer the control to another activity which further splits to the concurrent activities so the flow of control will pass to all the concurrent activities. It may also be the case that the flow control in concurrent activities may again combine to a single activity.
The notation for this kind of synchronization is shown which a heavy line which has multiple input and multiple outputs. As you can see in the figure of ‘activity diagram for processing stock’. While synchronization, the flow of control is active in all the incoming activities which are then transferred to all the outgoing activities.
To understand this let’s observe the figure of ‘activity diagram for processing stock’ when an order gets executed successfully three activities execute concurrently. Such as confirmation is sent to a customer, customers account is debited, his online portfolio is updated, all these activities are performed concurrently.
Once these activities are performed all of them merge to a single activity that closes the order.
5. Executable Activity Diagram
As we know the activity diagram shows the flow of control in a process. But an executable activity diagram has an activity token which indicates which activity is executing currently.
When the activity with an activity token completes the execution the activity token is moved to the outgoing arrow from the activity. In case the activity has multiple outgoing arrows that too with the condition then the activity token is passed to that successor activity whose executing condition is verified.
In case, the activity has multiple successive concurrent activities then the activity token also splits and is placed on the activities concurrently activated. When the concurrent activities complete execution the multiple tokens are merged.
Key Takeaways
- Activity diagram expresses the step by step computation of a complex process by showing the flow of control through the intermediate steps of the process.
- All the activities in the activity diagram must be at the same level.
- If you want to detail any activity in the diagram then elaborate it in a separate activity diagram.
- While planning the branches for the condition make sure that at least one of the conditions satisfies, you can also make use of else.
- Activity diagram can express the process with concurrent activities.
- The executable activity diagram helps to identify the activity getting executing currently.
So, this is all about the activity diagram, its behavior and its use. We have tried to detail every element of the activity diagram. We have also covered an example for a better understanding of the activity diagram.
Leave a Reply