R McFadyen 192.2911 Activity Diagrams Activity diagrams are used to present the procedural steps of...

28
1 92.2911 R McFadyen Activity Diagrams Activity Diagrams Activity diagrams are used to present the procedural steps of an algorithm An algorithm comprises any of the following structures: •sequence •decision •repetition

description

R McFadyen sequence

Transcript of R McFadyen 192.2911 Activity Diagrams Activity diagrams are used to present the procedural steps of...

Page 1: R McFadyen 192.2911 Activity Diagrams Activity diagrams are used to present the procedural steps of an algorithm An algorithm comprises any of the following.

192.2911R McFadyen

Activity DiagramsActivity Diagrams

Activity diagrams are used to present the procedural steps of an algorithm

An algorithm comprises any of the following structures:

•sequence

•decision

•repetition

Page 2: R McFadyen 192.2911 Activity Diagrams Activity diagrams are used to present the procedural steps of an algorithm An algorithm comprises any of the following.

292.2911R McFadyen

Activity DiagramsActivity Diagrams

start

end

branch

merge

fork

join

guard

transition

swimlanes

activity

Symbols

Page 3: R McFadyen 192.2911 Activity Diagrams Activity diagrams are used to present the procedural steps of an algorithm An algorithm comprises any of the following.

392.2911R McFadyen

sequencesequence

Page 4: R McFadyen 192.2911 Activity Diagrams Activity diagrams are used to present the procedural steps of an algorithm An algorithm comprises any of the following.

492.2911R McFadyen

sequencesequence

Activity 1 Activity 2 Activity 3

Activities 1, 2, 3 follow one another in sequence. Activity 3 cannot start until Activity 2 is done, etc.

Page 5: R McFadyen 192.2911 Activity Diagrams Activity diagrams are used to present the procedural steps of an algorithm An algorithm comprises any of the following.

592.2911R McFadyen

Example: instructions to make Zucchini RelishExample: instructions to make Zucchini Relish

Combine vegetables with pickling salt and leave overnight

Drain and rinse

Combine remainingIngredients withvegetables

Boil 20 minutes

Put in sterilized jars

Page 6: R McFadyen 192.2911 Activity Diagrams Activity diagrams are used to present the procedural steps of an algorithm An algorithm comprises any of the following.

692.2911R McFadyen

conditional path / 2-way switchconditional path / 2-way switch

Page 7: R McFadyen 192.2911 Activity Diagrams Activity diagrams are used to present the procedural steps of an algorithm An algorithm comprises any of the following.

792.2911R McFadyen

conditional path / 2-way switchconditional path / 2-way switch

Activity 1

Activity 2

[con

ditio

n 1]

[con

ditio

n 2]

One of two paths is chosen

Same symbol for decision as for merge

Page 8: R McFadyen 192.2911 Activity Diagrams Activity diagrams are used to present the procedural steps of an algorithm An algorithm comprises any of the following.

892.2911R McFadyen

Example: instructions to make Zucchini RelishExample: instructions to make Zucchini Relish

Combine vegetables with pickling salt and leave overnight

Drain and rinseCombine remainingIngredients withvegetables

Boil 20 minutesPut in sterilized jars

Go and purchase ingredients

[ Missing some ingredients ]

[ have all ingredients ]

Page 9: R McFadyen 192.2911 Activity Diagrams Activity diagrams are used to present the procedural steps of an algorithm An algorithm comprises any of the following.

992.2911R McFadyen

if ( count > 0 ) average = sum / count;else average = 0.0;System.out.println (average);

Example - programming

[ cou

nt >

0 ]

[ cou

nt <

= 0

]

Average sum/count

Average 0

Print average

Page 10: R McFadyen 192.2911 Activity Diagrams Activity diagrams are used to present the procedural steps of an algorithm An algorithm comprises any of the following.

1092.2911R McFadyen

multiway switchmultiway switch

Page 11: R McFadyen 192.2911 Activity Diagrams Activity diagrams are used to present the procedural steps of an algorithm An algorithm comprises any of the following.

1192.2911R McFadyen

multiway switchmultiway switch

Activity 1

Activity n

One of several paths is chosen

Same symbol for decision as for merge

Activity 2[condition2]

[condition1]

[condition n]

Page 12: R McFadyen 192.2911 Activity Diagrams Activity diagrams are used to present the procedural steps of an algorithm An algorithm comprises any of the following.

1292.2911R McFadyen

Example – multiway switchExample – multiway switch

switch (watts) {

case 40: price = 0.50;

break;

case 60: price = 0.69;

break;

case 75: price = 0.85;

break;

case 100:

case 150: price = 1;

break;

default: price = 0;

System.out.print (“No bulb ” +watts + “watts in stock”);

} // end switch

Page 13: R McFadyen 192.2911 Activity Diagrams Activity diagrams are used to present the procedural steps of an algorithm An algorithm comprises any of the following.

1392.2911R McFadyen

Example – multiway switchExample – multiway switch

Price 0.50[watts= 40]

Price 0.69

Price 0.85

Price 1.00

Price 0.00

[watts= 60]

[watts= 100 or 150]

[ watts < > 40, 60, 100, 150 ]

[watts= 75]

Print

No bulb message

Page 14: R McFadyen 192.2911 Activity Diagrams Activity diagrams are used to present the procedural steps of an algorithm An algorithm comprises any of the following.

1492.2911R McFadyen

iteration / loopingiteration / looping

Page 15: R McFadyen 192.2911 Activity Diagrams Activity diagrams are used to present the procedural steps of an algorithm An algorithm comprises any of the following.

1592.2911R McFadyen

iteration / loopingiteration / looping

Processing before test

[ exit condition ]

Processing after test

[ continue condition ]

Page 16: R McFadyen 192.2911 Activity Diagrams Activity diagrams are used to present the procedural steps of an algorithm An algorithm comprises any of the following.

1692.2911R McFadyen

int next; // the next number

int sum = 0; // the sum so far

int count = 0; // initialize loop counter

while (count < MAX) { // test loop counter

readInt(next); // get next number

sum = sum + next; // add next number to sum

count = count + 1; // increment loop counter

} // end loop

Example - programmingExample - programming

Page 17: R McFadyen 192.2911 Activity Diagrams Activity diagrams are used to present the procedural steps of an algorithm An algorithm comprises any of the following.

1792.2911R McFadyen

Increment count[ Count < Max ] Read next integer Add integerto sum

Sum 0

Count 0

Example - programmingExample - programming

Page 18: R McFadyen 192.2911 Activity Diagrams Activity diagrams are used to present the procedural steps of an algorithm An algorithm comprises any of the following.

1892.2911R McFadyen

parallelism/concurrencyparallelism/concurrency

Page 19: R McFadyen 192.2911 Activity Diagrams Activity diagrams are used to present the procedural steps of an algorithm An algorithm comprises any of the following.

1992.2911R McFadyen

parallelism/concurrencyparallelism/concurrency

Activity 1 Activity 2

Activity 3

Both paths are performed in parallel. Activity 1 and 2 begin when Activity 0 is finished.

Activity 0

Activity 4

Activity 4 begins when Activity 1 and 3 have both completed

Page 20: R McFadyen 192.2911 Activity Diagrams Activity diagrams are used to present the procedural steps of an algorithm An algorithm comprises any of the following.

2092.2911R McFadyen

Example: instructions to make Zucchini RelishExample: instructions to make Zucchini Relish

Combine vegetables with pickling salt and leave overnight

Drain and rinseCombine remainingIngredients withvegetables

Boil 20 minutesPut in sterilized jars

Chop onionsChop Zucchini Chop green peppers Chop red peppers

Page 21: R McFadyen 192.2911 Activity Diagrams Activity diagrams are used to present the procedural steps of an algorithm An algorithm comprises any of the following.

2192.2911R McFadyen

Example - Updating a Star SchemaExample - Updating a Star Schema

Page 22: R McFadyen 192.2911 Activity Diagrams Activity diagrams are used to present the procedural steps of an algorithm An algorithm comprises any of the following.

2292.2911R McFadyen

Example - Updating a Star SchemaExample - Updating a Star Schema

Churn Star Schema from The Official Guide to Informix/Red Brick Data Warehousing

Rate_planPeriod

Customer

Churn_reason

Carrier

Telephone

Churncredit_limitoutstanding_balancecurrent_bill

A Star Schema is a specialized ERD used in Data Warehousing.

To update the database, we:

(1) update each Dimension, and then

(2) update the Fact table

Page 23: R McFadyen 192.2911 Activity Diagrams Activity diagrams are used to present the procedural steps of an algorithm An algorithm comprises any of the following.

2392.2911R McFadyen

Example - Updating a Star SchemaExample - Updating a Star Schema

UpdateCustomer

Update Churn

UpdateRate plan

UpdateChurn Reason

UpdateTelephone

UpdateCarrier

UpdatePeriod

Page 24: R McFadyen 192.2911 Activity Diagrams Activity diagrams are used to present the procedural steps of an algorithm An algorithm comprises any of the following.

2492.2911R McFadyen

Example - Updating a Star SchemaExample - Updating a Star Schema

UpdateCustomer

Update Churn

UpdateRate plan

UpdateChurn Reason

UpdateTelephone

UpdateCarrier

UpdatePeriod

The dimensions can be updated independently of one another.

Those activities can be carried on concurrently

Page 25: R McFadyen 192.2911 Activity Diagrams Activity diagrams are used to present the procedural steps of an algorithm An algorithm comprises any of the following.

2592.2911R McFadyen

SwimlanesSwimlanes

Page 26: R McFadyen 192.2911 Activity Diagrams Activity diagrams are used to present the procedural steps of an algorithm An algorithm comprises any of the following.

2692.2911R McFadyen

SwimlanesSwimlanesOrg 1 Org 2 Org 3 An activity

diagram can be partitioned according to organizational units

Org n…

Page 27: R McFadyen 192.2911 Activity Diagrams Activity diagrams are used to present the procedural steps of an algorithm An algorithm comprises any of the following.

2792.2911R McFadyen

SwimlanesSwimlanes

Activity 1 Activity 2

Activity 3

Swimlanes

When we assign activities to particular organizational units, then we can partition the flow into swimlanes, one swimlane per unit.

Activity 0

Activity 4

Org 1 Org 2 Org 3 Org 4

Page 28: R McFadyen 192.2911 Activity Diagrams Activity diagrams are used to present the procedural steps of an algorithm An algorithm comprises any of the following.

2892.2911R McFadyen

SwimlanesSwimlanes

Workflow for an Order

Request product

Customer Sales Warehouse

A customer requests a product. The order is handled by Sales, and then the Warehouse picks the materials and ships the order. Then, the customer will receive the order and Sales will send out the bill. When the customer receives the bill, it is paid, and the order is closed by Sales.

ProcessOrder

Pick &Ship

ReceiveOrder

SendBill

Pay BillOrderClosed

ReceiveBill