Activity Diagrams • Derived from several techniques: • Event diagrams of Jim Odell • SDL state modeling techniques • Workflow modeling • Petri nets • Especially useful when: • Modeling a workflow • Modeling an operation • Describing behavior that has a lot of parallel processing
Activity • Activity is the state of doing something • Real-world process like typing a letter • Execution of a software routine like a method on a class. • Rounded rectangle is narrower and more oval-shaped than the state icon.
Activity Diagrams vs. State Diagrams • Activity diagram describes the sequencing of activities, with support for both conditional and parallel behavior • Activity diagram is a variant of a state diagram in which most, if not all, the states are activity states. • Much of the terminology used in Activity diagrams follows that of state diagrams.
Activity Diagrams • Activity diagrams: • allow the user to choose the order in which to do things • states the essential sequencing rules that must be followed • Flowcharts are limited to sequential processes, whereas activity diagrams can handle parallel processes
Forks & Joins • A join synchronizes parallel behavior • Forks and joins must match – every time you have a fork, you must have a join that combines the threads started by that fork.
Forks & Joins • Extensions to previous rule: • A thread that comes out of a fork can itself fork, with the new threads coming back together before reaching the matching join
Forks & Joins • Extensions to previous rule: • If a thread coming out of a fork goes straight to another fork, you can remove the second fork and just have the threads from the second fork coming out of the first fork.
Decomposing an Activity • An activity can be broken down into subactivities using notation similar to superstates and substates on a state diagram.
Swimlanes • Our activity diagrams so far have focused on what happens, but they do not tell you who does what. • Communication among responsible objects is missing. • Swimlanes can be used to arrange activity diagrams into “zones of responsibility.”
Assigning Objects to Activities • The task of assigning objects to activities should be done. • Should it be done immediately when initially diagramming activities, or later when an overall sense of the behavior is understood?
Activity Diagrams • Strengths • Support and encourage parallel behavior • Good tool for workflow modeling • Good tool for multithreading • Weaknesses • Links among actions and objects are not especially clear • Interaction diagrams are more helpful in this area
When to use Activity Diagrams • Analyzing a Use Case • Understanding Workflow • Describing a complicated sequential algorithm • Dealing with multithreaded applications
When not to use Activity Diagrams • Trying to see how objects collaborate • Trying to see how an object behaves over its lifetime • Representing complex conditional logic
ESU Revisited • Preparing for Registration • The process of preparing the course curriculum and making it available to the student community can be expressed using an Activity Diagram. • We don’t assign responsibilities to each activity at this time.
ESU Revisited • Preparing for Registration • We must make sure all courses have been assigned a professor
The UML and Design Flow Collaboration Diagram Use Case Sequence Diagram State Diagram Object Diagram Class Diagram Activity Diagram