Activity Diagram in UML Definition Activity diagrams represent

  • Slides: 23
Download presentation
Activity Diagram in UML

Activity Diagram in UML

Definition • Activity diagrams represent the dynamics of the system. • They are flow

Definition • Activity diagrams represent the dynamics of the system. • They are flow charts that are used to show the workflow of a system. • They show. – The flow of control from activity to activity in the system, – What activities can be done in parallel. – Alternate paths through the flow. • They can show the flow across use cases or within a use case.

Use Case for Order Processing (Generic system) • “When we receive an order, we

Use Case for Order Processing (Generic system) • “When we receive an order, we check each line item on the order to see if we have the goods in stock. If we do, we assign the goods to the order. If this assignment sends the quantity of those goods inn stock below the reorder level, we reorder the goods. While we are doing this, we check to see if the payment is OK. If the payment is OK and we have the goods in stock, we dispatch the order. If the payment is OK but we don’t have the goods, we leave the order waiting. If the payment isn’t OK, we cancel the order. ”

Combining Use Cases • The end point of an activity diagram is the point

Combining Use Cases • The end point of an activity diagram is the point at which all triggered activites have been run and there are no more left to do. • Dead ends (e. g. Reorder item) can occur. • Sometimes dead ends meet up with other use cases (e. g. Check line item).

Receiving Supply • “When a supply delivery comes in, we look at the outstanding

Receiving Supply • “When a supply delivery comes in, we look at the outstanding orders and decide which ones we can fill from this incoming supply. We then assign each of these to its appropriate orders. Doing this may release those orders for dispatching. We put the remaining goods into stock. ”

Drawback • Activity diagrams tell you what is happening, but not who does what.

Drawback • Activity diagrams tell you what is happening, but not who does what. • In domain modeling, this diagram type does not convey which people or departments are responsible for each activity. • In programming, it does not convey which class is responsible for each activity.

Swimlanes • Arrange activity diagrams into vertical zones separated by dashed lines. • Each

Swimlanes • Arrange activity diagrams into vertical zones separated by dashed lines. • Each zone represents the responsibilities of a particular class or department.

When to Use Activity Diagrams • Do use them for – Analysing Use Cases.

When to Use Activity Diagrams • Do use them for – Analysing Use Cases. – Understanding workflow across many Use Cases. – Dealing with multi-threaded applications. • Don’t use them – to see how objects collaborate. – to see how an object behaves over its lifetime.

Simbol Activity Diagram

Simbol Activity Diagram

Swimlanes • Object swimlane untuk menggambarkan objek mana yang bertanggung jawab untuk aktivitas tertentu.

Swimlanes • Object swimlane untuk menggambarkan objek mana yang bertanggung jawab untuk aktivitas tertentu.

Receive order * for each line item on order [failed] Authorise Payment Cancel Order

Receive order * for each line item on order [failed] Authorise Payment Cancel Order [succeeded] Check line item [in stock] Assign to Order [need to reorder] [stock assigned to all line items and payment authorised] Dispatch Order Activity Diagram for Receiving an Order Reorder item

Activity Diagram for receiving Supply Receive Supply Choose outstanding order items * for each

Activity Diagram for receiving Supply Receive Supply Choose outstanding order items * for each chosen order item Assign goods to order [all outstanding order items filled] Dispatch Order Add remainder to stock

Combined Activity Diagram Receive order * for each line item on order Authorise Payment

Combined Activity Diagram Receive order * for each line item on order Authorise Payment Check line item [failed] [succeeded] Cancel Order [in stock] Assign to Order [need to reorder] [stock assigned to all line items and payment authorised] Dispatch Order Receive Supply Choose outstanding order items * for each chosen order item Assign goods to order Reorder item [all outstanding order items filled] Add remainder to stock

Stock Manager Order Processing Finance Receive order Receive Supply * for each line item

Stock Manager Order Processing Finance Receive order Receive Supply * for each line item on order Authorise Payment Check line item [failed] [succeeded] Cancel Order [in stock] Assign to Order [need to reorder] [stock assigned to all line items and payment authorised] Dispatch Order Choose outstanding order items * for each chosen order item Assign goods to order Reorder item [all outstanding order items filled] With Swimlanes Add remainder to stock

Understanding Workflows – Each activity represents the performance of a group of actions in

Understanding Workflows – Each activity represents the performance of a group of actions in a workflow. – Once the activity is complete, the flow of control moves to the next activity or state through a transition. – If an outgoing transition is not clearly triggered by an event, then it is triggered by the completion of the contained actions inside the activity. – A unique activity diagram feature is a swimlane that defines who or what is responsible for carrying out the activity or state. – It is also possible to place objects on activity diagrams. – The workflow stops when a transition reaches an end state.

Placing an Activity diagram • Where? – You can attach activity diagrams to most

Placing an Activity diagram • Where? – You can attach activity diagrams to most model elements in the use case or logical views. – Activity diagrams cannot reside within the component view. • Why? – Very effective in illustrating the workflow of various events in a use-case diagram. – You can use activity diagrams to specify and define each event in a use-case diagram.

Creating an activity diagram • Modelling a workflow in an activity diagram – –

Creating an activity diagram • Modelling a workflow in an activity diagram – – – – – Identify a workflow objective. Decide the pre and post-conditions of the workflow. Define all activities and states. Define any objects that are created or modified. Decide on responsibility for performing the activities. Connect all elements on the diagram with transitions. Place decisions on the diagram. Evaluate your diagram for concurrent workflows. Set all actions, triggers and guard conditions in the specifications of each model element.

Identify a workflow objective. – "What needs to take place or happen by the

Identify a workflow objective. – "What needs to take place or happen by the end of the workflow? What needs to be accomplished? “ – For example, if your activity diagram models the workflow of ordering a book from an online bookstore, the goal of the entire workflow could be getting the book to the customer.

2. Workflow pre and postconditions – Define pre and post conditions of the workflow

2. Workflow pre and postconditions – Define pre and post conditions of the workflow through a start state and an end state. – In most cases, activity diagrams have a flowchart structure so start and end states are used to designate the beginning and ending of the workflow. – Start and end states clarify the perimeter of the workflow.

Define activities and states • Define and recognize all activities and states that must

Define activities and states • Define and recognize all activities and states that must take place to meet your objective. Place and name them on the activity diagram in a logical order.

Identify persistent object operations • Define and diagram any objects that are created or

Identify persistent object operations • Define and diagram any objects that are created or modified within your activity diagram. • Connect the objects and activities with object flows.

Add swimlanes • Decide who or what is responsible for performing the activities and

Add swimlanes • Decide who or what is responsible for performing the activities and states through swimlanes. • Name each swimlane and place the appropriate activities and states within each swimlane.

Finish diagram • Connect all elements on the diagram with transitions. • Place decisions

Finish diagram • Connect all elements on the diagram with transitions. • Place decisions on the diagram where the workflow may split into an alternate flow. – E. g. based on a Boolean expression, the workflow could branch to a different workflow. • Evaluate your diagram and see if you have any concurrent workflows. If so, use synchronizations to represent forking and joining. • Set all actions, triggers and guard conditions in the specifications of each model element.