JMU
Lab: Creating Activity Diagrams in Visual Paradigm


Instructions: Answer as many of the following questions as you can during the lab period. If you are unable to complete the assignment during the lab period it is strongly recommended that you complete it on your own.

1. General Preparation: Before doing anything else, if you haven't already done so, you should read a little about Visual Paradigm for UML.
  1. Open the course "Help" page on "Visual Paradigm - Tips".
  2. Read the section on "Colors, Fonts, etc...".
  3. Read the section on "Finding Icons".
  4. Read the section on "Exporting Diagrams".
2. Specific Preparation: If you haven't already done so, you should read a little about Activity Diagrams in Visual Paradigm for UML.
  1. Read the section on "Activity Diagrams".
3. Replicating an Example from Lecture: In this part of the lab you will replicate the following Activity Diagram that was used in lecture.
part1.png
  1. Add a new Activity (not a new Action) with a name of "Do Laundry".
  2. Resize the "Do Laundry" Activity so that it is large enough to handle all of the Action nodes.
  3. Add an Action named "Sort Clothes".
  4. Add an Activity Parameter (not an Object node) named "dirtyClothes" to "Do Laundry". (Note: Be careful to make it an input. That is,
  5. Right-click on "dirtyClothes", pull down to Open Specification and, on the General tab, change the Type to "Clothes" and click OK.
  6. Try to add a Control Flow from "dirtyClothes" to "Sort Clothes".
  7. What happens and why?


    It isn't allowed because control can't be passed from an Activity Parameter (or an Object node) to an Action node.
    Expand
  8. Add an Object Flow from "dirtyClothes" to "Sort Clothes".
  9. Add an Object node named "Whites".
  10. Right-click on "Whites", pull down to Open Specification.
  11. On the General tab, change the Type to "Clothes".
  12. On the InStates tab, add a state named "dirty", select it (if necessary), and click on OK.
  13. Right-click on "Whites", pull down to Presentation Options, pull across to Show InStates, and select Yes.
  14. Adjust the size of the "Whites" node as needed.
  15. Add a similar Object node named "Colors" and set its attributes.
  16. Add one Object Flow from "Sort Clothes" to "Whites" and another Object Flow from "Sort Clothes" to "Colors".
  17. Add two Action nodes, one named "Wash Whites" and one named "Wash Colors".
  18. Add one Object Flow from "Whites" to "Wash Whites" and another Object Flow from "Colors" to "Wash Colors".
  19. Which Action happens first, "Wash Whites" or "Wash Colors", or do they happen at the same time?


    This Activity Diagram does not specify. Either could happen first or they could happen at the same time. If we wanted to specifiy an order we would have to include a flow from one to another. If we wanted to specify that they happen at the same time then we would have to include a Fork Node. We'll do this later.
    Expand
  20. Add the Object Nodes for "Whites" and "Colors" that have states of "clean" and "wet".
  21. Add the Object Flows from "Wash Whites" to "Whites" and from "Wash Colors" to "Colors".
  22. Add the "Dry Clothes" Action.
  23. Re-size the "Dry Clothes" Action so that it is aligned on the left and right with the "Sort Clothes" Action.
  24. Add the Object Flows from "Whites" to "Dry Clothes" and from "Colors" to "Dry Clothes".
  25. When can/does the "Dry Clothes" Action begin?


    In general, an Action begins when tokens are available on all of the incoming edges. In this case, the "Dry Clothes" Action begins when both the "Whites" that are clean and wet and the "Colors" that are clean and wet are available.
    Expand
  26. Complete the Activity Diagram.
4. Modeling Parallel Actions: In this part of the lab you will modify the Activity Diagram so that it includes parallel actions as follows.
part2.png
  1. Increase the vertical size of the "Do Laundry" Activity. Note: You may need to move the input and output parameters.
  2. Select all of the nodes below "Whites [dirty]" and "Colors [dirty]" and move them lower.
  3. Delete the Object Flow into "Wash Whites" and the Object Flow into "Wash Colors".
  4. The Decision Node, Fork Node, and Join Node icons are stacked. Expand the stack and select the Fork Node icon.
  5. Add a Fork Node below the "Whites [dirty]" and "Colors [dirty]" nodes.
  6. If necessary, change the orientation of the Fork Node to horizontal and adjust its size.
  7. Add one Object Flow from "Whites [dirty]" to the Fork Node and another from "Colors [dirty]" to the Fork Node.
  8. Add one Control Flow from the Fork Node to "Wash Whites" and another from the Fork Node to "Wash Colors".
  9. Delete the two Object Flows into "Dry Clothes".
  10. Add a Join Node below the "Whites [clean, wet]" and "Colors [clean, wet]" nodes.
  11. If necessary, change the orientation of the Join Node to horizontal and adjust its size.
  12. Add Object Flows from the "Whites [clean, wet]" and "Colors [clean, wet]" nodes to the Join Node.
  13. Add a Control Flor from the Join Node to the "Dry Clothes" node.
  14. Now which Action happens first, "Wash Whites" or "Wash Colors", or do they happen at the same time?


    Now they happen in parallel.
    Expand
  15. In the real world, is it always possible to wash whites and colors at the same time?


    No, there may not be two washing machines available.
    Expand
5. Modeling Decisions: In this part of the lab you further modify the Activity Diagram so that it includes a decision and a timed event as follows.
part3.png
  1. Increase the vertical size and horizontal size of the "Do Laundry" Activity.
  2. Delete the Object Flow into "Sort Clothes".
  3. Add a "Put Clothes In Basket" Action above the "Sort Clothes" Action.
  4. Add an Object Flow from the "dirtyClothes" parameter to the "Put Clothes In Basket" Action.
  5. Add a "Go To Laundry Room" Action below the "Put Clothes In Basket" Action.
  6. Add a Decision node below the "Go To Laundry Room" Action. (Hint: Remember some icons are stacked.)
  7. Add a Control Flow from the "Go To Laundry ROom" Action to the Decision node.
  8. Add a Control Flow from the Decision node to the "Sort Clothes" Action.
  9. Place a Guard of "two washers available" on the Control Flow you just added.
  10. Add an Action named "Leave Laundry Room" to the right of the decision node.
  11. Add a Control Flow from the Decision node to the "Wait One Hour" Action.
  12. Place a Guard of "else" on the Control Flow you just added.
  13. Add an Accept Time Event Action named "Wait One Hour" above the "Leave Laundry Room" Action. (Hint: It is a kind of Action and its icon is stacked.)
  14. Add a Control Flow from the "Leave Laundry Room" action to the "Wait One Hour" Action.
  15. You might be inclined to add one Control Flow from "Put Clothes In Basket" to "Go To Laundry Room" and another Control Flow from "Wait One Hour" to "Go To Laundry Room". Why would this be inappropriate?


    An Action only begins executing when tokens are available on all incoming edges. So, if both of these Control Flows were added, it would be impossible for the "Go To Laundry Room" Action to every execute.
    Expand
  16. How can we resolve this problem?


    Use a Merge node (not to be confused with a Join node).
    Expand
  17. Add a Merge node between the "Put Clothes In Basket" Action and the "Go To Laundry Room" Action.
  18. Add the remaining Control Flows.

Copyright 2016