0% found this document useful (0 votes)
10 views

Lecture 4 - Activity Diagrams

Uploaded by

devmith2005
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Lecture 4 - Activity Diagrams

Uploaded by

devmith2005
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

ICT 1411

Object Oriented Programming

Lecture 3
Activity Diagrams
Introduction
• An activity diagram is a behavioral diagram i.e. it depicts the behavior of a system.
• Illustrate the flow of control in a system and refer to the steps involved in the execution
of a use case.
• Provide a high-level view of how a system's processes or workflows function.
• It shows the control flow from a start point to a finish point showing the various decision
paths that exist while the activity is being executed.
• Can depict both sequential processing and concurrent processing of activities using an
activity diagram.
• Shows ‘How’ for a particular system.
Elements of the Activity Diagram
• Activities
• Activities represent tasks or operations that are performed within a system.
• Shows the flow of control from one activity to another.
• The processing within an activity completes and then an automatic transition to the
next activity occurs.
• Example: In a banking system, activities could include "Withdraw Money," "Deposit
Money," and "Check Balance."
• Association
• Represent relationships or connections between activities.
• Illustrate the flow of control or data from one activity to another.
• Example: An association arrow from "Login" to "View Account" indicates that the
"View Account" activity follows the "Login" activity.
• Conditions
• Also known as guards, represent decision points in the flow of activities.
• Allow for branching based on certain conditions, enabling the modeling of decision-
making processes.
• Example: A condition could be represented as "If balance > 0," leading to different
activities based on whether the condition is true or false.
• Constraints
• Represent restrictions or limitations on the execution of activities.
• Provide additional information or rules that need to be considered during the
execution of an activity.
• Example: A constraint could be "[User must be authenticated]" associated with the
"Transfer Funds" activity.
Activity Diagram Notations
• Start / Initial State
• Used to represent the starting point or the initial state of an activity.

• Action or Activity State –


• An activity represents execution of an action on objects or by objects.
• Represent an activity using a rectangle with rounded corners.

Activity
Wake up

Eat breakfast

Sleep
• Action Flow or Control flows
• Action flows or Control flows are also referred to as paths and edges.
• They are used to show the transition from one activity state to another.

• Decision node and Branching


• When we need to make a decision before deciding the flow of control, we use the
decision node.
• These two paths are mutually exclusive.
• Fork
• Fork nodes are used to support concurrent activities.

• Join
• Join nodes are used to support concurrent activities converging into one.
• For join notations we have two or more incoming edges and one outgoing edge.
• Merge or Merge Event
• Scenarios arise when activities
which are not being executed
concurrently have to be merged.
• Use the merge notation for such
scenarios.
• Can merge two or more activities
into one if the control proceeds
onto the next activity irrespective
of the path chosen.
Inform
Customer
• Swimlanes
• Use swimlanes for grouping related
activities in one column.
• Swimlanes group related activities into one
column or one row.
• Swimlanes can be vertical and horizontal.
• Used to add modularity to the activity
diagram.
• It is not mandatory to use swimlanes.
• They usually give more clarity to the activity
diagram. It’s similar to creating a function in
a program.
• A recommended practice.
• Each swimlane shows the name of the role
at the top, and presents the activities of
each role.
• Final State or End State
• The state which the system reaches when a particular process or activity ends is
known as a Final State or End State.
• Use a filled circle within a circle notation to represent the final state in a state
machine diagram.
• A system or a process can have multiple final states.
How to draw an activity diagram

• Identify the initial state and the final states.


• Identify the intermediate activities needed to reach the final state from he initial state.
• Identify the conditions or constraints which cause the system to change control flow.
• Draw the diagram with appropriate notations.
Uses of an Activity Diagram

• Dynamic modelling of the system or a process.


• Illustrate the various steps involved in a UML use case.
• Model software elements like methods, operations and functions.
• We can use Activity diagrams to depict concurrent activities easily.
• Show the constraints, conditions and logic behind algorithms.
Exercise 1
• The following use cases can be identified in a learning management system for different
actors.
• Student
• Download Materials, Submit Materials, Take quizzes
• Teacher
• Upload Materials, Download Submissions, Make quizzes
• Admin
• Create user accounts, Create modules, Grant access to users

• Draw activity diagrams for each use case of the student.


Exercise 2
• Draw an activity diagram for the order processing procedure given below.

A sales representative enters details of new order. If the order requires special
materials that are not in stock, place order for special materials with supplier. Other
wise add order to production list. Then schedule a delivery date. If customer has e-
mail address, e-mail customer giving projected delivery date. If the customer does
not have a email address, generate letter to customer giving projected delivery
date.
Exercise 3
• Draw an activity diagram for the procedure of manufacturing order. Consider the
following details.
Company manufacturing is done in the workshop. Therefore the workshop requests next
order for manufacture. If the order is on holding list then issue order to Workshop.
Otherwise take next order from production list and check whether it is ready for
manufacture or not. If the order cannot be manufactured, add order to holding list. If
customer has e-mail address, e-mail customer advising of delay or generate letter to
customer informing of delay in case no email address for the customer. Then take next
order from production list. If the order is ready for manufacturing issue the order to the
workshop.
Exercise 4
• The following scenario explain how a passenger check-in can be done in an airline. Draw
an activity diagram to represent the procedure.
• When a passenger checks in, he or she first shows his or her ticket at the check-in
counter. The ticket will be checked for its validity. If the ticket is not OK the passenger will
be referred to customer service. If the ticket is OK the passenger will check his or her
luggage. If the luggage has excess weight he or she will pay an additional fee. The
luggage will be forwarded to baggage transportation. The passenger receives his or her
boarding pass.

You might also like