Modeling with UML
(ActivityDiagram)
Bernd Bruegge & Allen H. Dutoit ! ! Object-Oriented Software Engineering: Using UML, Patterns, and Java 1!
Activity Diagrams
• An activity diagram is a special case of a state chart
diagram
• The states are activities (“functions”)
• An activity diagram is useful to depict the workflow in a
system
Handle Document Archive
Incident Incident Incident
Bernd Bruegge & Allen H. Dutoit ! ! Object-Oriented Software Engineering: Using UML, Patterns, and Java 2!
Activity Diagrams allow to model Decisions
Decision"
[lowPriority]
Open Allocate
Incident Resources
[fire & highPriority]
[not fire & highPriority]
Notify
Fire Chief
Notify
Police Chief
Bernd Bruegge & Allen H. Dutoit ! ! Object-Oriented Software Engineering: Using UML, Patterns, and Java 3!
Activity Diagrams can model Concurrency
• Synchronization of multiple activities
• Splitting the flow of control into multiple threads
Allocate
Splitting! Resources Synchronization!
Open Coordinate Archive
Incident Resources Incident
Document
Incident
Bernd Bruegge & Allen H. Dutoit ! ! Object-Oriented Software Engineering: Using UML, Patterns, and Java 4!
Activity Diagrams: Grouping of Activities
• Activities may be grouped into swimlanes to
denote the object or subsystem that
implements the activities.
Allocate! Dispatcher!
Resources!
Open! Coordinate! Archive!
Incident! Resources! Incident!
FieldOfficer!
Document!
Incident!
Bernd Bruegge & Allen H. Dutoit ! ! Object-Oriented Software Engineering: Using UML, Patterns, and Java 5!
Activity Diagram vs. Statechart Diagram
Statechart Diagram for Incident!
Focus on the set of attributes of a single abstraction (object, system)!
Event causes"
state transition"
Active ! Inactive ! Closed ! Archived !
Incident-! Incident-! Incident-!
Handled ! Documented ! Archived !
Activity Diagram for Incident !
(Focus on dataflow in a system) !
Handle Document Archive
Incident Incident Incident
Triggerless"
Completion of activity " transition"
Bernd Bruegge & Allen H. Dutoit ! ! Object-Oriented Software Engineering: Using UML, Patterns, and Java 6!
causes state transition"
Activity Diagram – document management process
Bernd Bruegge & Allen H. Dutoit ! ! Object-Oriented Software Engineering: Using UML, Patterns, and Java 7!
Exercise: Activity Diagram
• Draw an activity diagram for fulfillment of an order,
(i.e., an order is received, it is processed, invoice is
produced, delivered either overnight or regular, and
payment is received before the order is closed).
Bernd Bruegge & Allen H. Dutoit ! ! Object-Oriented Software Engineering: Using UML, Patterns, and Java 8!
Exercise: Activity Diagram
Bernd Bruegge & Allen H. Dutoit ! ! Object-Oriented Software Engineering: Using UML, Patterns, and Java 9!
UML Summary
• UML provides a wide variety of notations for representing many
aspects of software development
− Powerful, but complex
• UML is a programming language
− Can be misused to generate unreadable models
− Can be misunderstood when using too many exotic features
• We concentrated on a few notations:
− Functional model: Use case diagram
− Object model: class diagram
− Dynamic model: sequence diagrams, statechart and activity
diagrams
Bernd Bruegge & Allen H. Dutoit ! ! Object-Oriented Software Engineering: Using UML, Patterns, and Java 10!