Professional Documents
Culture Documents
Slides Ilearn
Slides Ilearn
andreas.woelfl@th-deg.de
UNIFIED MODELING LANGUAGE
UNIFIED MODELING LANGUAGE
1. MOTIVATION
MOTIVATION
Model
A representation of a system using rules and concepts.
price(size) = wo + w1 · size
design
Benefits:
Diagram
Behaviour Structure
Diagram Diagram
Campus Management
Grant ETCS
Professor
Announce exam
Actor
A basic UML element that represents a user that is interacting with a system.
Professor
• Actors interact with the system by using (or being used by) the use case.
• Represent roles that humans or non-humans (systems) adopt.
• Named by a noun.
Use Case
A basic UML element that describes a unit of useful functionality performed by
the system.
Grant ETCS
System boundary
A rectangle to separate use cases that are internal to a system from the actors
that are external to the system.
Campus Management
Announce exam
Association relationship
A solid line to visualize a connection between an actor and a use case.
Announce exam
Professor
Include relationship
A dashed arrow described with <<includes>> indicating that the behavior of
one use case is integrated in the behavior of another use case.
Campus Management
Assign lecturer
«include»
Announce lecture
Professor
Extends relationship
A dashed arrow described with <<extends>> indicating that the behavior of one
use case is integrated in the behavior of another use case, but does not have to.
Campus Management
Inheritance relationship
A solid line with a triangle arrow head representing a parent-child relationship
between use cases or actors.
Example:
Campus Management
Announce event
Professor
«extends»
Announce exam Announce lecture
A
X
{abstract} C
A B
Exercise: Create a use case diagram for an ATM machine including at least:
• 3 Actors
• 5 Use cases
• 1 Generalization
ATM
Deposit money
Bank
Withdraw
Customer
Check balance
Administrator
Read log
3. CLASS DIAGRAM
CLASS DIAGRAM
Example:
contains
Course
Class
A rectangle that describes an entity of a system, i.e. represents a set of objects
that share a common structure or behavior.
Course
name: string
semester: SemesterType
hours: float
getCredits(): integer
getLecturer(): Lecturer
getGPA(): float
setHours(hours: float) : void
Access Right public (⃝) private (□) protected (♢) package (△)
Member of the same class yes yes yes yes
Member of a derived class yes no yes yes
Member of any other class yes no no if in package
Association relationship
A solid line that depicts a semantic connection between two classes.
givesLecturesFor
Professor Student
Multiplicity
An indicator of how many objects may be associated with exactly one object of
the opposing side.
Professor Course
1..2 *
• Many: *
• n or more: 0..*, 1..*, 5..*
• Exact number: 0, 1, 5
• Exact range: 0..1, 0..5
Navigability
An indicator that specifies whether an object can access the visible attributes
and methods of objects on the opposing side.
Professor Student
Role
A label that describes the way in which an object is involved in an association
relationship.
Professor Student
+ lecturer
xor constraint
A dashed line representing that An object of class A is to be associated with an
object of class B or an object of class C, but not with both.
Office LectureHall
1 1
{xor}
* *
Exam
Unary Association
An unary association relationship is when two partner objects from the same
class are involved in the relationship.
+examiner
examines
Person
+examinee
n-ary Association
An n-ary association relationship is when more than two partner objects from
different classes are involved in the relationship.
Student Lecturer
0..* 0..1
+examiner
0..*
Exam
Association Class
A class attached to an association to assign attributes and operations to the
relationship.
StudyProgram Student
* 1..*
Enrollment
startDate: Date
enroll()
drop()
• No duplicates allowed, i.e., one student can enroll in one particular study
program exactly once.
Aggregation
A form of association that expresses that a class is part of another class.
StudyProgram Course
1..* *
Composition
A form of association that expresses that a class is part of another class.
Building LectureHall
1 *
Generalization
A form of association that represents an is a relationship.
Realization
A form of association that represents a relationship between an interface and a
class, where the class provides the implementation.
Student Employee
Professor
• A university consists of multiple faculties which are composed of various institutes. Each
faculty and each institute has a name. An address is known for each institute.
• Each faculty is led by a dean, who is an employee of the university.
• The total number of employees is known. Employees have a social security number, a name,
and an email address. There is a distinction between research and administrative personnel.
• Research associates are assigned to at least one institute. The field of study of each research
associate is known. Furthermore, research associates can be involved in projects for a certain
number of hours, and the name, starting date, and end date of the projects are known. Some
research associates hold courses. Then they are called lecturers.
• Courses have a unique number (ID), a name, and a weekly duration in hours.
Employee
le a d s Faculty
sosec_nr: integer
1 +dean 0..1
name: string name: string
email: string
Research Institute
Administrative Associate
Employee 1..* 1..* name: string
field_of_study: string address: string
1..*
Participation
Lecturer
hours: integer
1..*
teaches
1..* 0..*
Course Project
4. SEQUENCE DIAGRAM
SEQUENCE DIAGRAM
Sequence Diagram
Visual representation of the interactions and message exchanges among
objects or components in a system or process.
Example:
:Application :Database
execute_query()
result_set
Lifeline
Representation of the existence of an object over a period of time.
Interaction
An arrow representing the exchange of a message between objects.
:Application :Database
query(statement)
result_set
process(result_set)
An activation box represents the period of time during which an object is active.
Types of messages:
• Syncronous message
:A :B
• Sender waits until response received
• Syntax: msg(p1,p2,...) << synchronous >>
• Asyncronous message
:A :B
• Sender continues without waiting
• Syntax: msg(p1,p2,...) << asynchronous >>
• Response message
:A :B
• May be omitted if content and location are obvious
• Syntax: variable: "value" < < re s p o n s e > >
Order of messages:1
:A :A :B :A :B
a a a
c b
c
c
1
The operator ”→” stands for ”happens before”
Prof. Dr. Andreas Wölfl Advanced Programming Techniques 42
SEQUENCE DIAGRAM
Combined Fragments
Logical groupings, represented by a rectangle, which contain structures
affecting the flow of messages.
2
https://www.omg.org/spec/UML/2.5/PDF
Prof. Dr. Andreas Wölfl Advanced Programming Techniques 43
SEQUENCE DIAGRAM
Alt Fragment
Combined fragment that represents a conditional branch.
:Person :ATM
withdraw(amount)
Opt Fragment
Combined fragment that represents an optional branch.
register(matrNr, exam)
enter(matrNr, exam)
status
enterWL(matrNr, exam)
enterWL: "ok"
register: "ok"
[else]
register: "error"
Loop Fragment
Combined fragment that represents a repetitive loop or iteration.
Note: The loop condition is only executed after the minimum number of loops.
Break Fragment
Combined fragment that represents the premature termination of a loop or
iteration.
Example:
check(user, pass)
register(matrNr, exam)
enter(matrNr, exam)
picks up
dial tone
ring
ring notification
picks up
"Hello"
"Hello"
5. ACTIVITY DIAGRAM
ACTIVITY DIAGRAM
Activity Diagram
Visual representation of a workflow of stepwise activities and actions
supporting choices, iteration, and concurrency.
no
credentials correct?
yes
Show homescreen
Action
A basic UML element to specify user-defined behavior.
Attend lecture
Edges
A basic UML element to connect actions to one another.
Attend lecture
Write exam
Decision Node
Control node that represents a test condition to ensure that the flow only goes
down one path.
Merge Node
Control node that brings back together different decision paths that were
created by a decision node.
5
counter?
Fork Node
Control node that has one incoming edge
and multiple outgoing edges to split the Register
Join Node
Control node that brings back together
Write exam
(and synchronizes) a set of concurrent
flows.
CheckAccount
Withdrawal Deposit
no yes
sufficientFunds
Reject HandoutCash
UpdateBalance
6. SUMMARY
SUMMARY
• DrawIO3
• Eclipse Papyrus4
• PlantUML5
3
https://app.diagrams.net
4
https://www.eclipse.org/papyrus/
5
https://plantuml.com/
Prof. Dr. Andreas Wölfl Advanced Programming Techniques 62
SUMMARY
Best practices:
6
Keep it simple, stupid!
Prof. Dr. Andreas Wölfl Advanced Programming Techniques 63
SUMMARY
Summary
You should have accquired the following competencies: