Um L Class Diagram Tutorial
Um L Class Diagram Tutorial
The UML Class diagram is a graphical notation used to construct and visualize object oriented
systems.
What is a class?
A class in an object oriented system provides a crisp abstraction of a well defined set of
responsibilities.
Page 1 of 8
Visibility and Access for attributes and operations of a class
The +, - and # symbols before an attribute and operation name in a class denote the visibility of
the attribute and operation.
+ denotes public attributes or operations
- denotes private attributes or operations
# denotes protected attributes or operations
Access for each of these visibility types is shown below for members of different classes.
Page 2 of 8
Operation (Method) Parameter Directionality
Each parameter in an operation (method) may be denoted as in, out or inout which specifies its
direction with respect to the caller. This directionality is shown before the parameter name.
Page 3 of 8
Relationships between classes
A class may be involved in one or more relationships with other classes.
A relationship can be one of the following types: (Refer to the figure on the right for the
graphical representation of relationships)
Relationship Type Graphical Representation
Inheritance (or Generalization):
Represents an “is-a” relationship.
An abstract class name is shown in
italics.
Association
Simple association:
o A structural link between
two peer classes.
o There is an association
between Class1 and Class2
Page 4 of 8
Composition: A special type of
aggregation where parts are
destroyed when the whole is
destroyed.
o Objects of Class2 live and
die with Class1.
o Class2 cannot stand by itself.
Dependency:
o Exists between two classes if
changes to the definition of
one may cause changes to
the other (but not the other
way around).
o Class1 depends on Class2
Page 5 of 8
A class diagram may also have notes attached to classes or relationships. Notes are shown in
grey.
An Example
Page 6 of 8
Exercise 1
Consider the following UML Class Diagram snippets. Choose the type of relationship between
classes given below.
Page 7 of 8
4. Student and Schedule
a. Dependency
b. Generalization(Inheritance)
c. Association
d. Composition
e. Aggregation
f. No relationship exists
5. ClientDisplay and Supplier
a. Dependency
b. Generalization(Inheritance)
c. Association
d. Composition
e. Aggregation
f. No relationship exists
6. Department and Company
a. Dependency
b. Generalization(Inheritance)
c. Association
d. Composition
e. Aggregation
f. No relationship exists
7. InventoryItem and DVD
a. Dependency
b. Generalization(Inheritance)
c. Association
d. Composition
e. Aggregation
f. No relationship exists
Page 8 of 8