תרשים המחלקות ותרשים העצמים
1
חלק שלישי :ניתוח ועיצוב מערכות מידע
באמצעות שימוש בUML-
ומתודולוגיית ה)UP( Unified Process-
E2
2
3
E1
Outline
UML Introduction
Class Diagram
Class
Association
Self association
Aggregation & Composition
Dependency
Object Diagram
Association
Class Diagram: Qualifiers
Class Diagram: Association Class
Class Diagram: Inheritance (Generalization)
3
UML Introdcution - Modeling
A model is a simplification of reality.
Through modeling we achieve four aims:
1. Models help us to visualize a system as it is or as we want it to be.
2. Models permit us to specify the structure or behavior of a system.
3. Models give us a template that guides us in constructing a system.
4. Models document the decisions we have made.
4
UML Introdcution
Donald Bell, Staff, IBM. 15 Jun 2003:
Way back in the late twentieth century -- 1997 to be exact -- the Object
Management Group (OMG) released the Unified Modeling Language
(UML).
One of the purposes of UML was to provide the development
community with a stable and common design language that could be
used to develop and build computer applications.
UML brought forth a unified standard modeling notation that IT
professionals had been wanting for years.
Using UML, IT professionals could now read and disseminate system
structure and design plans -- just as construction workers have been
doing for years with blueprints of buildings.
5
UML – Unified Modeling Language
Visualizing, specifying, constructing, and documenting object-
oriented systems is exactly the purpose of the UML.
Exactly like architects blueprints.
The constructing part is debatable.
You already know how to speak it (Object-Oriented); here you
will learn to read and exercise writing it.
6
The Diagrams of UML 2.0
Class diagram (s)
Interaction diagram (i)
Object diagram (s)
Communication diagram (i)
Sequence diagram (i)
Timing diagram (i)
State machine (b)
Activity diagram (f)
Use Case diagram (f)
Component diagram (s)
Package diagram (s)
Composite diagram (s)
These ones – we’ll see…
Classification of diagrams:
Deployment diagram (s)
…these ones – we won’t.
(s) – structure
(b) – behavior
(f) – functional
(i) – interaction
7
Class Diagram
Definition:
A class diagram is a graphic presentation of the
static view
that shows a collection of declarative (static) model elements, such as
classes, types, and their content, and relationships.
8
Class Diagram Basic Elements:
Class
Elements
Visual Representation
Class
Name
Typed Attributes
Typed Methods
A class is a description of a set of objects that share the
same attributes, operations, relationships, and semantics.
9
Class Diagram Basic Elements:
Association
Visual Presentation
Elements
Association
Name
Roles’ name
multiplicity
name
multiplicity
-role
-role
Multiplicity
a
a..b
a..*
Association
Association - a structural relationship that specifies that objects of one
thing (class) are connected to objects of another.
Aggregation - an association between two classes or components
defined as “is part of”.
Composition - a strong form of aggregation.
10
Class Diagram Basic Elements:
Self Association
Association can be between
a class and itself.
Recursive data structures,
self-reference…
Examples: Class Inheritance
and Polymorphism,
University Courses with PreRequisites.
How would you model a
nodes-and-edges graph?
11
Class Diagram Basic Elements:
Composition
Composition has exactly two
rules which differ it from
ordinary associations:
A constituent part can belong
to exactly one assembly.
Once a constituent part has
been assigned an assembly, it
has a coincident lifetime with
the assembly.
12
Class Diagram Basic Elements:
Aggregation
Aggregation…
… is a “Modeling Placebo” –
does not have any actual
semantics.
…would be treated just like
association in code generation,
model analysis, etc.
13
Class Diagram Basic Elements:
Association – Aggregation and Composition
Wrong!
Right!
14
Class Diagram Basic Elements:
Dependency
Dependencies - is a relationship that states that one thing
(class) uses the information and services of another thing
(class).
Underline is the notation for static operation/attributes.
Some patterns reduce dependencies usage to a minimum.
15
tio
n
V
U
is cop
M
ua y
L
En
lP ]
te
ar
r
ad
pr
fo
ig
i
rU
se
m
M
Ed
fo
L
rU
itio
En
M
n
te
L
[e
rp
En
va
ris
l
te
u
e
Vi
a
rp
Ed
tio
su
ris
n
iti
al
e
on
Vi co
Pa
Ed
s
p
[
u
y
e
ra
iti
al
]
va
on
di
Pa
lu
gm
[e
at
r
a
va
i
fo
on
di
lu
rU
g
m
co
at
M
io
py
fo
L
n
r
]
En
co
U
M
py
te
L
rp
]
En
ris
t
e
er
Ed
pr
is
iti
e
on
Ed
[e
iti
va
on
lu
[e
at
va
io
Vi
Vi
n
lu
su
su
co
at
al
al
io
p
Pa
Pa
y]
n
co
ra
ra
py
di
di
gm
gm
]
fo
fo
rU
rU
M
M
L
L
En
En
te
te
rp
rp
ris
ris
e
e
Vi
V
E
Ed
i
su
su
di
iti
al
a
tio
on
l
Pa
Pa
n
[
[e
ev
ra
ra
va
di
di
a
l
lu
gm
gm
ua
at
tio
io
fo
f
or
n
n
rU
co
co
U
M
M
p
py
L
L
y]
]
En
En
te
te
rp
rp
ris
ris
e
e
Ed
Ed
iti
iti
on
on
[e
[e
va
va
lu
lu
at
at
io
io
חברת טיולים- 1 דוגמה
רשימת ערים, לכל טיול יש שם. חברת טיולים מארגנת טיולים מסוגים שונים
מספר ימי, מדינה, עיר מוגדר ע"י שם העיר. תאריך יציאה ותאריך חזרה,לביקור
, מדריך יכול להדריך בערים שונים.) שם וכתובת,ז.לביקור ופרטיו של המדריך (ת
. עבור כל טיול מנהלים רשימת מטיילים.אך לכל עיר יכול להיות מדריך אחד בלבד
.מספר) ומחיר לטיול, רשימת טלפונים (קוד, שם,ז.מטייל מוגדר ע"י ת
City
Tour
al
Vi
su
-code
-number
Vi
su
al
Pa
ra
di
gm
Pa
ra
d
U
M
L
fo
r
ig
m
Pa
ra
d
al
Vi
su
Telephon
0..*
1..*
-name
-country
-days
0..*
0..*
1..*
1
ig
m
fo
r
En
te
rp
ris
e
Ed
itio
n
[e
v
al
ua
-name
-departure
-arrival
0..*
1
Tourist
-id
-name
-cost
Guide
-id
-name
-address
?) מה יותר מובן (הסיפור או הדיאגראמה
16
co
[e
va
lu
at
[e
va
[e
va
lu
at
io
n
Ed
itio
n
Ed
iti
on
Ed
itio
n
En
te
rp
ris
e
En
te
rp
ris
e
En
te
rp
ris
e
דוגמה - 2קורסים באוניברסיטה
UM
L
M
L
U
fo
r
fo
r
fo
r
al
Pa
ra
di
gm
Vi
su
Vi
su
al
Pa
ra
di
gm
al
Pa
ra
di
gm
section of
Seminar
*1..
takes
*0..
Student
Vi
su
Course
UM
L
באוניברסיטה ניתנים קורסים .כל קורס יכול להיות מורכב ממספר סמינרים (אך לא
חייב) .לסמינר משובצים סטודנטים .כל סטודנט חייב להשתתף לפחות בסמינר אחד.
עוזר ההוראה של הסמינר הוא סטודנט.
-student
*0..
*0..
1
-teaching assistant
assists
roles ו associations-מאוד חשובים להבנת התרשים והמערכת ⇐ השתמשו בהם.
ברירות המחדל של multiplicityמבלבלות ובעייתיות ⇐ ציינו במפורש את ה.multiplicity-
17
Object Diagram
It depicts objects and their relationships at a certain point in
time, typically a special case of either a class diagram or a
communication diagram [Scott W.Ambler].
It shows instances instead of classes.
They are useful for explaining small pieces with complicated
relationships, especially recursive relationships. [Randy Miller]
It is closely linked to class diagram. Just as an object is an
instance of a class, an object diagram could be viewed as an
instance of a class diagram.
It is used for testing and refining class diagram.
18
Object Diagram Basic Elements:
Links and Associations
Visual Presentation
Elements
Object
Name
object name : class
Attributes
-attribute 1 = "value"
-attribute 2="value"
-...........
-attribute n="value"
Links
:class
object name : class
Name
Type
Association
Aggregation
Composition
Generalizations
Dependencies
-role
name
-role
link
Why there is no multiplicity?
19
En
te
rp
ri
M
L
UM
L
En
te
rp
ri
En
te
UM
L
1..*
Seminar
-student
-teaching assistant
3 דוגמה
al
Pa
ra
di
gm
takes
Vi
su
0..*
Vi
su
al
Pa
ra
di
gm
fo
r
fo
r
U
fo
r
al
Pa
ra
di
gm
Vi
su
Student
)2 (המשך מדוגמא
section of
Course
0..*
0..*
1
assists
a) Right OD
b) Wrong OD
sem1 : Seminar
amir : Student
takes
tali : Student
assists
amir : Student
assists
cou1 : Course
assists
sem1 : Seminar
assists
sem2 : Seminar
takes
sem1 : Seminar
ooad : Course
ooad : Course
20
En
te
rp
ris
e
M
L
al
Pa
ra
di
gm
Seminar
Vi
su
1..*
section of
3 דוגמה
fo
r
U
fo
r
takes
Vi
su
al
Pa
ra
di
gm
0..*
-student
-teaching assistant
UM
L
En
te
rp
ris
e
En
te
rp
UM
L
fo
r
al
Pa
ra
di
gm
Vi
su
Student
)(המשך
Course
0..*
0..*
1
assists
?תקין/ שגויOD •
. associations-לגרוע על כמות ה/ לא יכולה לעלותlinks-• כמות ה
21
En
te
rp
ris
e
M
L
UM
L
En
te
rp
ris
e
En
te
rp
UM
L
1..*
Seminar
-student
al
Pa
ra
di
gm
takes
Vi
su
0..*
Vi
su
al
Pa
ra
di
gm
fo
r
fo
r
U
fo
r
al
Pa
ra
di
gm
Vi
su
Student
4 דוגמה
section of
Course
0..*
{NAND}
0..*
-teaching assistant 0..1
assists
?תקין/ שגויOD •
sem1 : Seminar
takes
tali : Student
takes
amir : Student
assists
cou1 : Course
assists
sem2 : Seminar
takes
sem1 : Seminar
ooad : Course
22
Class Diagram: Qualifiers
במדינה יש כמה ערים ולכולם שמות שונים -מה מהבאים הכי נכון?
.a
.b
.c
23
Class Diagram: Association Class
An association class is an association whose links
have identities.
It is possible to define a association class if
relationship between classes has additional
properties.
Association class constraint:
A single instance of the association between any 2 instances of the
associated class (the regular association constraint).
An association class can have attributes.
24
Association Class – Definitive Example
/etc/termcap
/etc/termcap
/usr/does/.login
read
read-write
read-write
John
Mary
John
Doe
Brown
Doe
A rule of thumb
Association classes are better for many to many relationships.
25
– עובדים בפרויקט5 דוגמה
יש לשמור את תיאור. עובדים משובצים לפרויקטים שונים בתפקידים שונים
.התפקיד ומשכורת של עובד פר פרויקט עליו הוא עובד
a) Class Diagram
b) Object Diagram
DavidP1:Role
-description="manager"
-salary="10..."
David:Employee
p1:Project
OrenP1:Role
-description="tester"
-salary="50..."
p2:Project
Oren:Employee
OrenP2:Role
-description="tester"
-salary="50..."
The constraint comes from the association semantics.
26
What do the diagrams describe ?
a)
b)
c)
27
Class Diagram: Inheritance (Generalization)
Inheritance models “is a” and “is like” relationship, enabling
you to reuse existing data and code easily.
The subclass inherits from super-class:
Attribute
Operation
Relationship
Interface
28
Class Diagram: Inheritance (Generalization)
Some patterns:
Create a conceptual subclass of a super-class when:
1. The subclass has additional attributes of interest.
2. The subclass has additional associations of interest.
3. The subclass concept is operated on, handled, reacted to, or
manipulated differently than the super-class or other subclasses, in
ways that are of interest.
4. The subclass concept represents an animate thing (for example,
animal, robot) that behaves differently than the super-class or other
subclasses, in ways that are of interest.
29
Class Diagram: Inheritance (Generalization)
Create a conceptual super-class in a generalization
relationship to subclasses when:
1. The potential conceptual subclasses represent variations of a similar
concept.
2. The subclasses will conform to the 100% and Is-a rules.
3. All subclasses have the same attribute which can be factored out and
expressed in the super-class.
4. All subclasses have the same association which can be factored out
and related to the super-class.
30
Representing Abstract Concepts and
their Concrete Manifestations
What is a flight?
The plane?
The path?
Both – but in two
different contexts?
So let’s represent it!
31
© Copyright 2026 Paperzz