Thursday, June 10, 2010

Creating Activity Diagram in UML

You use an activity diagram to model the flow of control of a particular process. Next, you identify the interactions among use cases and derive dependencies among use cases.

Identifying the Need for Activity Diagrams.

To design a process, you need to define the actions that constitute the process and the order in which they execute.

An activity Diagram uses activities to model objects, classes, interfaces, components, and nodes. An activity represents a set of actions, such as call to a method of a class, send or receive a signal, create or destroy an object, and evaluate an expression.

The basic elements of an activity diagram are:

 Action state: - Represents the state of the System in terms of action.

 Activity state: - Represents an activity and therefore this state can further expand into another activity state or action state.

 Transition: - Represents the control flow that performs a particular operation.

 Decision: - Represents the if-else or branch condition that decides the path of the control flow.
Identifying Flows, Partitions, and Pins

These elements improve the clarity of the activity diagram and model additional elements, such as transformation and object flows.

• Flows: - A flow or an edge represents the relationship between two action.

How many type of flows.

Two types of flows

 Control flow: Represents the relationship among activities and the I/O object of the activities.

The figure shows represent the control flow.



NOTE-A solid arrow between the activities depicts the control flow. You can also label the arrow to depict the role name in the activity diagram. A role name describes the role of the arrow in accomplishing the overall activity.

 Object flow: - represents a path along which object or data can pass.

The figure shows represent the Object flow.


 
NOTE: - It is represented by a dashed arrow between an element of the activity diagram and the state of an object.
• Partitions: - the elements of an activity diagrams focus only on the behavior of the process and not on the object that initiate the process. Using partitions, you can group the activity states that are responsible for invoking a particular operation. A partition creates logical groups of activity states so that each group represents the responsibility of a particular class.


• Signals: - signals are the events that occur outside the process but still have an impact on the process.

The figure shows represent the signals.



NOTE: -An activity diagram can depict both, sending and receiving a signal. You use a concave pentagon to model the signal receipt and a convex pentagon to model signal sending.

•What is Pins and transformations.

Pins: - Action can have parameters that flow one action state to another. Pins enable you to represent the input and output parameters of the activity states in an activity diagram.

Transformations: - The type of output parameters of an outbound action state should match the type of input parameters of the inbound action state. If this is not achieved, you need to use transformations on the parameters of the out bound actions. Transformations convert the type of output parameters of the outbound action to the required parameter type of the inbound action.

The following figure depicts the activity diagram with the transformations and pins for the process of canceling the order.


NOTE: -Transformation are show on each of the outgoing transformation and are modeled within a pair of angle brackets as <> followed by the name of the transformation. The name consists of an input parameter and output parameter separated by a period. Consider that in online transaction system, you need to intimate the customer about the cancellation of an order with the appropriate reason. The cancel order state send the parameter, order, to the intimate customer state, which is transformation into Reason and order no parameters.

• Expansion regions

An expansion region represents a group of actions and is nested inside an activity. It gets a collection of values as input and produces the same number of value as output. Activity diagrams also allow you to model sequential and parallel flows.

Implements an expansion region in the three modes

 Concurrent: - executes each element independently and concurrently. If the type of mode for the expansion region is not specified, the action is executed in the concurrent mode.

 Iterative: - executes each input element in the order in which the element enters into expansion region.

 Stream: - executes each element in a random order. All the input element enter the expansion region at the same time. Next, the actions contained in the expansion region operate on the input randomly.

The following figure show the expansion region for the online transaction system, which executes each input concurrently.


NOTE: - List of product ids is passed as the input collection to the expansion region. The action states, Discount on product and Net sales price of each product, compute the net price of each product. The output collection, list of product prices, which indicate the net price of each of each product, is passed to the activity state, charge bill, to compute the bill.

Explain the Flow final.

The action state that does not have any outgoing transition is depicted by a special symbol called flow final. Although flow final indicates the end of a particular flow, it does not represent the end of an activity.

The following figure depicts the activity diagram for the flow final.



Explain the Fork and join.

You use a fork to model parallel flows. In other words, you use forks to represent a flow converted into two or more independent flow that can process simultaneously.
At joins, two or more concurrent flows combine to form a flow. The join element enables you to join the control flows that should occur before the control come to another activity state. At a join, one transition groups various transitions.

1 comment:

Macy Dalby said...

Thanks this info was really helpful! I used a website called Lucidchart to create my own activity diagram and it was really easy to understand. If you use diagrams often you should check it out!

Recent Posts