Professional Documents
Culture Documents
Activity Diagram - Notes and Questions
Activity Diagram - Notes and Questions
Activity Diagram - Notes and Questions
Contents
1 Activity Diagrams 2
1.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2 Questions 8
OOSE Object Oriented Software Engineering — Activity Diagrams Page 2 of 15
1 Activity Diagrams
1.1 Overview
Activity diagrams are similar to flow charts: they describe the order of activity and the
branch logic of a process. However, they differ from traditional flow charts by allowing
the representation of concurrent operations. Activities that take place simultaneously (such
as threads) can be represented using activity diagrams.
Activity diagrams flow from top to bottom. The initial state is represented by a closed
(solid) circle. Activity proceeds through a series of activity states until it reaches its final
state, which is represented by a closed circle inside an open circle.
Figure 1 is a simple activity diagram based on a check out asset use case1 of a
library system. Boxes with rounded corners represent activity states. Each activity state
is labeled with a brief description of the activity it represents. The arrows between states,
called transitions, represent the shift from one activity state to the next.
Decisions or conditional actions in an activity diagram are actions that depends on one
or more defined requirements. Branches represent places where conditionals are used for
decisions in the activity flow. When a transition enters a branch, a question is asked and a
decision is made to continue the flow in one of two or more possible paths of execution. The
paths exiting a branch are called alternative threads because execution continues along
only one path. Figure 1 illustrates a branching with two alternative threads. A diamond
represents the branch. The transitions exiting the branch are labeled to indicate which
alternative each represents. The alternative threads converge at a merge, also represented
by a diamond. By convention, the primary thread of execution follows a straight path down
the page.
Activity diagrams can handle multiple branching (“if–else if – else”) scenarios. Figure 2
illustrates an activity diagram for the use case Add Asset to Database2 using multiple
Figure 1: An example of branch and merge for Check Out Asset use case (see footnote 1).
decision handling.
1
Check Out Asset Use Case: The system shall permit librarians to check assets out on behalf of
patrons. Patrons must supply a library card containing a bar code to be scanned by the librarian. The
bar-codded number shall be used to refer to the patron’s account information and determine whether an
overdue fine is owed before allowing another asset to be checked out. The librarian will scan the bar code
affixed to an asset being checked out, and the asset will be added to the patron’s account information and
marked as checked out in the asset database.
2
Add Asset to Database Use Case: The system shall permit head librarians to add library assets
such as books, magazines, newspapers, microfilm, and audiocassets to the asset database. A bar code sticker
affixed to the asset by a librarian will be scanned and used to refer to the asset within the system’s asset
database.
• Books and audiocassets are within 21 days.
• Magazines are due within two days.
• Newspapers cannot be checked out.
• Microfilm is due within three hours.
Figure 3: An example of a fork and join for the Check Out Asset use case (see footnote 1
on page 5)
Figure 4: Iterations
2 Questions
4. Forks and joins distinguish activity diagrams from traditional flow charts.
5. The arrows between states do not necessarily represent the shift from one
activity state to the next.
7. Diamond symbols represent places where conditionals are used for decisions
in the activity flow.
11. When a transition enters a fork, execution branches off in two or more
directions simultaneously.
15. Forks and joins are represented by bars, with two or more concurrent
threads.
16. Transitions exiting the branch are labeled to indicate which alternative
each represents.
17. An activity state may or may not be labeled with a brief description of
the activity it represents.
18. Transitions represent the shift from one activity state to the previous.
19. Threads converge at a join.
20. Alternative threads converge at a merge.
21. Decisions and merges are both represented by a diamond.
11. Among the primary and the alternative threads, which execution follows a straight path?
(d) Diamonds?
(e) Bar?
Match the most appropriate term to each concept. Not all terms are used. No term is used
twice.
9. Threads converge at a .
12. Which element of an activity diagram does not exist in Figure 5. A. Branching.
B. Forking. C. Joining. D. Merging. E. Iteration.
13. represent places where conditionals are used for decisions in an activity
flow.
A. Merges B. Forks C. Branches D. Iterations
Workout.
1. Draw an activity diagram based on the following Requirements Document.
(Hint: Modify figure 2 on page 4).
Add Asset to Database Use Case
A certain library system permits head librarians to add library assets such as books,
magazines, newspapers, and microfilm to the asset database. A bar code sticker affixed
to the asset by a librarian will be scanned and used to refer to the asset within the
system’s asset database.