Class Diagram PDF
Class Diagram PDF
Information Systems
REQ120130 - Requirement Engineering
Class Diagrams
Contributors:
Classes
Fields and Operations
Association
Composition
Generalization
Interfaces and Abstract Classes
Classes
Name
class Student { Attributes
private long studNum ;
private String name ;
public Student( long sn, String nm ) { Operations
studNum = sn ; name = nm ; }
public String getName() { return name ; }
public long getNumber() { return studNum ;}
}
UML Representation of a class
Association
Aggregation
Composition
Dependence
Generalization
Association Relationships
Each Department is
associated with one
DepartmentHead and at
least one
DepartmentMember
Each DepartmentHead
and DepartmentMember
is associated with one
Department
No constraint means
multiplicity is unspecified
Role names
An arrow-head
indicates the direction
of navigability.
E.g. Given a student
object, we can easily
find all Sections the
student is taking.
No arrow-head: means
navigability in both
directions.
Implementing navigable associations
*
Implementing associations indirectly
DepartmentHead getHead() {
return heads.get(this) ; }
…
}
Aggregation
Aggregation is a special
case of association.
It is used when there is
a “whole-part”
relationship between
objects.
Composition
Student Student
Record Number
Recursive associations
Represents “is-a-kind-
of’’ relationships.
E.g. every Chimp is
also an Ape.
In OO implementation it
represents class
inheritance: Inheritance
of interface and of
implementation too.
Interfaces
Classes “specialize”
classes, but “realize”
interfaces. Similar
concept, similar
notation. (Note dashes)
Choice of notations.
Diagrams at right are
equivalent.
Generalization/Specialization and Realization in Java
class TestCharInput
extends TestInput
implements CharSource
{
…
}
The Substitution Principle