1 / 26

Activity Diagrams

Activity Diagrams. Used to present the procedural steps of an algorithm An algorithm comprises any of the following structures: sequence decision Repetition An algorithm may also involve parallelism (are there some activities that can be done concurrently?). Activity Diagrams. Symbols.

jun
Download Presentation

Activity Diagrams

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Activity Diagrams • Used to present the procedural steps of an algorithm • An algorithm comprises any of the following structures: • sequence • decision • Repetition • An algorithm may also involve parallelism (are there some activities that can be done concurrently?) 91.3913 R McFadyen

  2. Activity Diagrams Symbols start end branch merge fork transition activity join guard swimlanes 91.3913 R McFadyen

  3. Activity Diagrams - sequential 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. 91.3913 R McFadyen

  4. Example: instructions to make Zucchini Relish Combine vegetables with pickling salt and leave overnight Drain and rinse Boil 20 minutes Combine remaining Ingredients with vegetables Put in sterilized jars 91.3913 R McFadyen

  5. Activity Diagrams – conditional path / 2-way switch Activity 1 [condition 1] [condition 2] Activity 2 One of two paths is chosen Same symbol for decision as for merge 91.3913 R McFadyen

  6. Example: instructions to make Zucchini Relish [ Missing some ingredients ] [ have all ingredients ] Go and purchase ingredients Drain and rinse Combine remaining Ingredients with vegetables Combine vegetables with pickling salt and leave overnight Boil 20 minutes Put in sterilized jars 91.3913 R McFadyen

  7. example if ( count > 0 ) average = sum / count; System.out.println (average); Average  sum/count [ count > 0 ] Print average [ count <= 0 ] 91.3913 R McFadyen

  8. example if ( count > 0 ) average = sum / count; else average = 0.0; System.out.println (average); Average  sum/count [ count > 0 ] Print average Average  0 [ count <= 0 ] 91.3913 R McFadyen

  9. example if ( x > 0 ) if (y > 0) { z = sqrt (x) + sqrt (y); System.out.println(“z = “ + z); } else System.out.println( “*** can’t compute z”); [ x <= 0 ] [ x > 0 ] [ y > 0 ] [ y <= 0 ] Print cannot compute Z Z  sqrt (x) + sqrt (y) Print Z 91.3913 R McFadyen

  10. example if (pH < 3) System.out.println( "Solution is very acidic.”); else if (pH < 7) System.out.println( "Solution is acidic.”); else if (pH == 7) System.out.println(”Solution is neutral."); else if(pH < 12) System.out.println( "Solution is alkaline.”); else System.out.println( "Solution is very alkaline.”); [ pH < 3 ] Print “very acidic” [ pH >= 3 ] [ pH < 7 ] Print “acidic” [ pH >= 7 ] [ pH = 7 ] [ pH <> 7 ] Print “neutral” [ pH < 12 ] Print “alkaline” [ pH >= 12 ] Print “very alkaline” 91.3913 R McFadyen

  11. Activity Diagrams – multiway switch [condition1] Activity 1 [condition2] Activity 2 Activity n [condition n] One of two paths is chosen Same symbol for decision as for merge 91.3913 R McFadyen

  12. Example – multiway switch switch (watts) { case40: price = 0.50; break; case60: price = 0.69; break; case75: price = 0.85; break; case 100: case150: price = 1; break; default: price = 0; System.out.print (“No bulb ” +watts + “watts in stock”); } // end switch 91.3913 R McFadyen

  13. Example – multiway switch [watts= 40] Price 0.50 [watts= 60] Price 0.69 Price 0.85 [watts= 100 or 150] Price 1.00 [watts= 75] Print No bulb message Price 0.00 [ watts < > 40, 60, 100, 150 ] 91.3913 R McFadyen

  14. Activity Diagrams – iteration / looping Processing before test [ exit condition ] [ continue condition ] Processing after test 91.3913 R McFadyen

  15. Activity Diagrams – iteration / looping Its not the way you draw it … it’s the way control flows that’s important Processing before test Processing after test [ continue condition ] [ exit condition ] 91.3913 R McFadyen

  16. example 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 91.3913 R McFadyen

  17. example Sum  0 Count  0 Read next integer Add integer to sum Increment count [ Count < Max ] 91.3913 R McFadyen

  18. example Sum  0 If we wish, we could put the exact code into the activities Count  0 readInt(next); sum = sum + next; count = count + 1; [ Count < Max ] 91.3913 R McFadyen

  19. Activity Diagrams – parallelism/concurrency Activity 0 Both paths are performed in parallel. Activity 1 and 2 begin when Activity 0 is finished. Activity 2 Activity 1 Activity 4 begins when Activity 1 and 3 have both completed Activity 3 Activity 4 91.3913 R McFadyen

  20. Example: instructions to make Zucchini Relish Chop Zucchini Chop onions Chop green peppers Chop red peppers Combine vegetables with pickling salt and leave overnight Drain and rinse Combine remaining Ingredients with vegetables Put in sterilized jars Boil 20 minutes 91.3913 R McFadyen

  21. Zucchini Relish 12 cups chopped Zucchini 4 large onions, chopped 2 red peppers, chopped 2 green peppers, chopped 1/3 cup pickling salt 3 cups white vinegar 4 cups white sugar 3 tbsp. Cornstarch 2 tsp. Celery seed 2 tsp. Mustard seed 2 tsp. Turmeric 91.3913 R McFadyen

  22. Updating a Star Schema 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 Customer Rate_plan Period Churn credit_limit outstanding_balance current_bill Telephone Churn_reason Carrier Churn Star Schema from The Official Guide to Informix/Red Brick Data Warehousing 91.3913 R McFadyen

  23. Updating a Star Schema Update Customer Update Rate plan Update Telephone Update Carrier Update Churn Reason Update Period Update Churn 91.3913 R McFadyen

  24. Updating a Star Schema Update Customer Update Rate plan Update Telephone Update Carrier Update Churn Reason Update Period The dimensions can be updated independently of one another. Those activities can be carried on concurrently Update Churn 91.3913 R McFadyen

  25. Activity Diagrams Org 1 Org 2 Org 3 Org 4 Activity 0 Swimlanes When we assign activities to particular organizational units, then we can partition the flow into swimlanes, one swimlane per unit. Activity 2 Activity 1 Activity 3 Activity 4 91.3913 R McFadyen

  26. Activity Diagrams Customer Sales Warehouse Workflow for an Order Request product 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. Process Order Pick & Ship Receive Order Send Bill Receive Bill Order Closed Pay Bill 91.3913 R McFadyen

More Related