CENG325 - 4 - UML Diagrams-Part1
CENG325 - 4 - UML Diagrams-Part1
1
Outline
▪ What is UML and why we use UML?
▪ UML Diagrams
▪ Use case Diagram
▪ Sequence Diagram
▪ State Diagram
▪ Activity Diagram (Flowchart)
▪ Class Diagram
2
What is UML?
➢ Diagramming language designed for Object-Oriented programming
3
Do we really need UML?
◼ Software project is not done by a single person! Complex applications
need collaboration and planning from multiple teams and hence require
a clear and concise way to communicate amongst them.
◼ Picture is worth a thousand words! A lot of time is saved down the line
when teams are able to visualize processes, user interactions and static
structure of the system.
4
More description about UML:
◼ UML uses graphical notations to express the OO analysis and design of software
projects.
7
Use-Case Diagrams
◼ A use-case diagram is a set of use cases
◼ Use cases specify the expected behavior (what), and not the
exact method of making it happen (how).
9
Actor
◼ Someone interacts with use case (system function).
◼ Named by noun.
◼ Actor plays a role in the business
◼ Actor triggers use case(s).
◼ Actor has a responsibility toward the system (inputs)
◼ and Actor has expectations from the system (outputs).
10
Finding Actors
➢ External objects that produce/consume data:
➢ Must serve as sources and destinations for data
➢ Must be external to the system
11
Finding Actors (2)
➢ Ask yourself the following questions:
• Who uses the system?
• Who installs the system?
• Who starts up the system?
• Who maintains the system?
• Who shuts down the system?
• What other systems use this system?
• Who gets information from this system?
• Who provides information to the system?
12
Primary & secondary actors
13
Use Case
◼ System function (process - automated or manual)
◼ Named by verb + Noun (or Noun Phrase).
◼ i.e. Do something
◼ Each Actor must be linked to a use case, while some
use cases may not be linked to actors.
◼ Communication Link
◼ The participation of an actor in a use case is shown by
connecting an actor to a use case by a solid link.
◼ Actors may be connected to use cases by associations,
indicating that the actor and the use case communicate
with one another using messages.
◼ System Boundary:
◼ entire system as defined in the requirements
document.
◼ For large and complex systems, each module
may be the system boundary.
15
Example:
16
Example:
17
Use Case Relationship: Include
19
Use Case Relationship: Generalization
◼ A generalization relationship is a parent-child relationship
between use cases.
◼ The child use case is an enhancement of the parent use case
(inherits properties and behavior of the parent and may override
them)
20
Use-Case Diagram Examples
◼ Both Make Appointment and
Request Medication include
Check Patient Record as a
subtask (include)
22
Use-Case Diagram Examples
◼ University
Management
System:
23
Use-Case Diagram Examples
◼ ATM machine system:
◼ An automated teller machine (ATM) or the automatic banking machine
(ABM) is a banking subsystem (subject) that provides bank customers
with access to financial transactions in a public space without the need for
a cashier, clerk, or bank teller.
◼ Customer (actor) uses bank ATM to Check Balances of his/her bank
accounts, Deposit Funds, Withdraw Cash and/or Transfer Funds (use
cases).
◼ ATM Technician provides Maintenance and Repairs.
◼ All these use cases also involve Bank actor whether it is related to
customer transactions or to the ATM servicing.
24
Use-Case Diagram Examples
ATM
machine
system:
25
Outline
▪ What is UML and why we use UML?
▪ UML Diagrams
▪ Use case Diagram
Sequence Diagram
▪ State Diagram
▪ Activity Diagram (Flowchart)
▪ Class Diagram
26
Scenario of Use cases
◼ Typically each use case includes a primary scenario ( or main
course of events) and zero or more secondary scenarios that are
alternative courses of events to the primary scenario.
27
UML Sequence Diagram
◼ Describe the flow of messages, events, actions between objects
◼ Show time sequences that are not easily depicted in other diagrams
Picks up
Object Dial tone Message
direction
Dial
29
Sequence Diagram main elements
31
Lifeline of the object
Creation
33
More details
• "opt" Operator
• The opt (optional) operator is an optional • « alt » operator
step in the flow • A test instruction
• The sequence of this fragment only (condition) with one or
executes if the guard [condition] is true multiple alternatives..
[if-then-else]
• Example: the user requests from the system
to return a ticket
34
More details
account
CardHolder
• « loop » operator
loop [3]
• Allowing to execute a sequence of sendPin ( )
interactions while a certain condition is verifyPin ( )
evaluated as true
…
:Class1 :Class2
par
operation1 ( ) operation2 ( )
37
Sequence Diagram Examples
ATM ‘withdraw’
sequence Diagram
38
Music playlist based on face emotion:
An application that takes the image of the user via the webcam and based
on a face detection algorithm that predicts the mood, it generate a song
playlist and show it to the user.