0% found this document useful (0 votes)
32 views18 pages

Class Diagrams

The document discusses various types of relationships that can exist between classes in a class diagram, including association, aggregation, generalization, and dependency relationships. It defines these relationships and how they are graphically represented. It also covers concepts like roles, multiplicity, and how to denote these using adornments on the relationship lines.

Uploaded by

Santa claus
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views18 pages

Class Diagrams

The document discusses various types of relationships that can exist between classes in a class diagram, including association, aggregation, generalization, and dependency relationships. It defines these relationships and how they are graphically represented. It also covers concepts like roles, multiplicity, and how to denote these using adornments on the relationship lines.

Uploaded by

Santa claus
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 18

Agenda

 Class Diagrams
 Class Relationships

1
Association Relationships

If two classes in a model need to communicate with each other, there must
be link between them.

An association denotes that link.

Student Instructor
Terms and Concepts
 An association is …
 A type of relationship that can exist between one
or more classes.
 Either unidirectional or bi-directional.
 Graphically represented by a solid line which may
optionally be labeled and have a name direction
indicator.
 Association names are verbs or verb phrases.

3
Terms and Concepts
 Associations may optionally have role names
and multiplicity symbols on either end of the
association line (next to the class icon).
 Role
 The face that a class on one end of an association
presents to the class on the other end of the
association.
 A class can participate in many associations and
thus have multiple (different) roles.
 Role names are usually nouns.
 Role names are usually used in place of
association names.

4
Association Relationships (Cont’d)

We can indicate the multiplicity of an association by adding multiplicity


adornments to the line denoting the association.

The example indicates that a Student has one or more Instructors:

Student Instructor
1..*
Association Relationships (Cont’d)

The example indicates that every Instructor has one or more Students:

Student Instructor
1..*
Association Relationships (Cont’d)

We can also indicate the behavior of an object in an association (i.e., the role
of an object) using rolenames.

teaches learns from


Student Instructor
1..* 1..*
Association Relationships (Cont’d)

We can also name the association.

membership
Student Team
1..* 1..*
Associations (cont.)

 Multiplicity
 the number of objects that participate in the
association.
 Indicates whether or not an association is
mandatory.
Multiplicity Indicators
Exactly one 1
Zero or more (unlimited) * (0..*)
One or more 1..*
Zero or one (optional association) 0..1
Specified range 2..4
Multiple, disjoint ranges 2, 4..6, 8
9
Terms and Concepts
 Multiplicity
 Indicates how many object may be connected
across an instance of an association.
 Aggregation is …
 A relationship between two classes.
 A form of association.
 Used to show a ‘has-a’ or a ‘whole-part’
relationship.
 Graphically represented as a solid line with an
open diamond on the ‘whole’ end.

10
Examples

11
Generalization
 A generalization is …
 A type of relationship that can exist between two
classes. One of the classes is the base (or
parent) class; the other class is the derived (or
child) class.
 Used to show a ‘kind-of’ relationship.
 Another name for inheritance.
 All OO programming languages support single
inheritance; some (C++) also support multiple
inheritance.
 Graphically represented by a solid line with an
open triangular arrowhead on the base class end.
 The parent class has no knowledge of the
child class. 12
Terms and Concepts

13
Dependency
 A dependency is ...
 A type of relationship that can exist between two
classes.
 An indication that one class ‘uses’ another class.
 If the ‘used’ class changes it can have an impact
on the ‘using’ class.
 Graphically represented as a dashed line with an
open arrowhead on one end.
 Rarely labeled.
 The “used” class has no knowledge of the
“using” class.

14
Examples

15
Examples

16
UML Class Diagram Examples
Example of identifying Class Relations, Multiplicities,
Attributes and operations

You might also like