Activity Diagram - Notes and Questions

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

Microlink Information Technology College

Notes and Questions on Activity Diagrams – February 7, 2022

Degree Program: CS and SE Class: NA


Course Title: OOSE Semester: 1st
Course Code: CS-421 Time duration: NA
Teacher’s name: Terefe Feyisa Total Marks: NA
Student’s name: Exam Date: NA
School Id. No:

Contents

1 Activity Diagrams 2

1.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

1.2 Decisions: Branches and Merges . . . . . . . . . . . . . . . . . . . . . . . . . 2

1.3 Handling Multiple Branches . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

1.4 Concurrency: Forks and Joins . . . . . . . . . . . . . . . . . . . . . . . . . . 5

1.5 Loops (Iterations) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

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.

1.2 Decisions: Branches and Merges

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.

1.3 Handling Multiple Branches

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

MicroLink Teacher terefefeyisa@gmail.com Please go on to the next page…


OOSE Object Oriented Software Engineering — Activity Diagrams Page 3 of 15

Figure 1: An example of branch and merge for Check Out Asset use case (see footnote 1).

MicroLink Teacher terefefeyisa@gmail.com Please go on to the next page…


OOSE Object Oriented Software Engineering — Activity Diagrams Page 4 of 15

Figure 2: Add Asset to Database activity diagram (see footnote 2 on page 5)

MicroLink Teacher terefefeyisa@gmail.com Please go on to the next page…


OOSE Object Oriented Software Engineering — Activity Diagrams Page 5 of 15

decision handling.

1.4 Concurrency: Forks and Joins


While branches are useful for describing when there are two or more options to take,
there are also situations where the action will flow along two or more paths at the same
time. This is known as concurrency. For instance, considering the Check Out Asset use-
case (see footnote 1 on the previous page), when an asset is being checked out, there are
two actions that must be performed at the same time: adding that asset to the patron’s
account information and marking that asset as checked out. These situations are described
in Activity Diagrams through forks and joins as depicted in Figure 3.
Forks and joins distinguish activity diagrams from traditional flow charts. When a
transition enters a fork, execution branches off in two or more directions simultaneously.
The threads exiting a fork operate concurrently. Threads converge at a join. Consider the
Check Out Asset use-case described above. This sequence can be represented using a fork.
Figure 3 adds a fork, represented by a horizontal bar, with two concurrent threads. After
an asset is scanned, execution continues along each of these threads simultaneously. The
threads converge at a join, also represented by a horizontal bar.

1.5 Loops (Iterations)


There are situations which will require certain actions to be performed more than once
before an entire process can be completed. These situations can be described using iterations.
An iteration is a step in a process which will repeat until a certain requirement is met. In
the following example, consider a student working on a school test. Until all the problems
on the test are completed, the student will not be finished working on the test. The loop
above the activity state of Completing Test Questions (see Figure 4) indicates that this
step will be iterated until all the questions are answered.

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.

MicroLink Teacher terefefeyisa@gmail.com Please go on to the next page…


OOSE Object Oriented Software Engineering — Activity Diagrams Page 6 of 15

Figure 3: An example of a fork and join for the Check Out Asset use case (see footnote 1
on page 5)

MicroLink Teacher terefefeyisa@gmail.com Please go on to the next page…


OOSE Object Oriented Software Engineering — Activity Diagrams Page 7 of 15

Figure 4: Iterations

MicroLink Teacher terefefeyisa@gmail.com Please go on to the next page…


OOSE Object Oriented Software Engineering — Activity Diagrams Page 8 of 15

2 Questions

Say TRUE or FALSE (All are about activity diagrams)


1. Conventionally, the primary thread of execution follows a straight path.

2. Decisions are actions that depends on undefined requirements.

3. Situations which require certain actions to be performed more than once


before an entire process can be completed can be described using iterations.

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.

6. Activity diagrams are not different from flow charts.

7. Diamond symbols represent places where conditionals are used for decisions
in the activity flow.

8. Activity diagrams flow from bottom to top.

9. 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.

10. An iteration is a step in a process which will repeat until a certain


requirement is met.

11. When a transition enters a fork, execution branches off in two or more
directions simultaneously.

12. Initial state is represented by a closed circle inside an open circle.

13. The paths exiting a branch are called alternative threads.

14. Final state is represented by a closed circle.

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.

MicroLink Teacher terefefeyisa@gmail.com Please go on to the next page…


OOSE Object Oriented Software Engineering — Activity Diagrams Page 9 of 15

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.

Explain (in association with a activity diagram)

Iterations Flow Charts Alternative Threads


Primary Thread Concurrent Operations Decisions
Branches Activities Diamond Symbol
Forks Threads Merge
Joins Initial State
Activity Diagram Transitions
Conditional Actions Final State

Essay questions (On activity diagrams)


1. What situations are represented by iterations?

2. What distinguish activity diagrams from traditional flow charts?

3. What are decisions or conditional actions?

4. What is an activity diagram?

5. Compare and contrast activity diagrams with flow charts.

MicroLink Teacher terefefeyisa@gmail.com Please go on to the next page…


OOSE Object Oriented Software Engineering — Activity Diagrams Page 10 of 15

6. What is the limit (number of decisions) in branching processes?

7. What do branches represent?

8. Where do threads converge?

9. What would happen when a transition enters a branch?

10. Where do alternative threads converge?

11. Among the primary and the alternative threads, which execution follows a straight path?

12. In an activity diagram, what do the following elements depict?


13. What would happen when a transition enters a fork?

(a) A solid circle?

(b) A solid circle inside an open circle?

(c) Rounded boxes?

(d) Diamonds?

MicroLink Teacher terefefeyisa@gmail.com Please go on to the next page…


OOSE Object Oriented Software Engineering — Activity Diagrams Page 11 of 15

(e) Bar?

14. What is the purpose of an activity diagram?

Fill in the blank questions by Matching

Match the most appropriate term to each concept. Not all terms are used. No term is used
twice.

Forks and joins top alternative threads


Decisions bottom Diamond
Activity diagram Initial state join
merge Final state Iteration
Threads Transitions

1. The paths exiting a branch are called .

2. is represented by a closed (solid) circle.

3. distinguish activity diagrams from traditional flow charts.

4. is a step in a process which will repeat until a certain requirement is met.

5. describe the order of activity and the branch logic of a process.

6. are actions that depend on one or more defined requirements.

7. are activities that take place simultaneously.

8. represents a branching. represent the shift from one activity


state to the next.

9. Threads converge at a .

10. Activity diagrams flow from to .

11. is represented by a closed circle inside an open circle.

MicroLink Teacher terefefeyisa@gmail.com Please go on to the next page…


OOSE Object Oriented Software Engineering — Activity Diagrams Page 12 of 15

12. Alternative threads converge at a , also represented by a diamond.

Choose the best answer (all about an activity diagram)


1. The paths exiting a branch are called .
A. primary threads B. forks C. merges D. alternative threads E. joins
2. are actions that depends on one or more defined requirements.
A. Decisions B. Conditional actions C. Primary threads D. Alternative
threads E. Only A and B F. Only C and D
3. distinguish activity diagrams from traditional flow charts..
A. Forks and joins B. Branches and merging C. Forks and merging D. Branches
and joins E. None of the above
4. Which one of the following is wrong about an activity diagram?
A. It is completely different from a flow chart.
B. Unlike a flow chart, it describes the order of activity.
C. Unlike a flow chart, it describes the branch logic of a process.
D. It allows the representation of concurrent operations.
E. All but D.
F. A and B only.
G. B and C only.
5. What would happen when a transition enters a branch?
A. A question is asked and a decision is made.
B. A decision is made to continue the flow with only one of two possible paths
of execution.
C. A decision is made to continue the flow in one of two or more possible paths
of execution.
D. A question is asked and an iteration follows.
E. Only A, B and C.
F. Only A and C.
G. Only C and D.
6. are steps in a process which will repeat until a certain requirement is
met.
A. Decisions B. Iterations C. Primary threads D. Alternative threads
E. Only A and B F. Only C and D

MicroLink Teacher terefefeyisa@gmail.com Please go on to the next page…


OOSE Object Oriented Software Engineering — Activity Diagrams Page 13 of 15

Figure 5: An activity diagram for a hypothetical use case.

7. A diamond symbol in an activity diagram marks .


A. joining B. decision C. forking D. merging E. B and D F. A and C
G. A and D

8. What is true about an activity diagrams?


A. activities flow randomly from top to bottom or vice-versa.
B. The final state is represented by a closed circle inside an open circle.
C. Activity states are labeled with a brief description of the activity in question.
D. Arrows represent the shift from one activity state to the previous.
E. All but C and D.
F. A, B and C only.
G. B, C and D only.

Use Figure 5 to answer questions 9, 10, 11 and 12.

9. What can be said about nodes N and G (refer Figure 5)?


A. N is decision node G is merge node.
B. N is decision node G is join node.
C. N is merge node G is decision node.

MicroLink Teacher terefefeyisa@gmail.com Question 9 continues on the next page…


OOSE Object Oriented Software Engineering — Activity Diagrams Page 14 of 15

D. N is join node G is merge node.


E. N is join node G is decision node.
F. Both N and G are decision nodes.
G. Both N and G are join nodes.
H. Both N and G are merge nodes.

10. Which one of the following is true (see Figure 5)?


A. Nodes A and M respectively indicate initial and final states.
B. Nodes C, D, E and F are concurrent activities.
C. Nodes I, J, K and L are concurrent activities.
D. Nodes G and N are decision nodes.
E. B and D only.
F. A, C and D only.
G. A, B and C only.
H. All but A and D .

11. In Figure 5, how many activities are shown?


A. 2 B. 4 C. 8 D. 10 E. 14 F. 16

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

14. What would happen when a transition enters a fork?


A. Execution continues in a sequential manner.
B. Execution branches off in two or more directions simultaneously.
C. A decision is made to continue the flow in one of two or more possible paths
of execution.
D. A question is asked and an iteration follows.

15. Threads that exit from forks converge at .


A. merges B. forks C. joins D. A and B E. A and C

MicroLink Teacher terefefeyisa@gmail.com Please go on to the next page…


OOSE Object Oriented Software Engineering — Activity Diagrams Page 15 of 15

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.

• Magazines are due within five days.


• Newspapers are due within five days.
• Microfilm is due within three hours.
• Books are due within three days.

MicroLink Teacher terefefeyisa@gmail.com End of note and questions

You might also like