Class Diagram
Class Diagram
Class Diagram
ICT381
M.J. Simfukwe
Unified Modeling Language
• 2 categories of diagrams
– Structure Diagrams
• Provide a way for representing the data and
static relationships that are in an information
system
• Behavior Diagrams
Structure Diagrams
• Class Diagram
– Describe the structure of the system in
terms of classes and objects
– Primary purpose during analysis
workflow: to create a vocabulary that is
used by both the analyst and users
What is a Class?
• A general template that we use to
create specific instances or objects in
the application domain
• Represents a kind of person, place, or
thing about which the system will
need to capture and store information
• Abstractions that specify the attributes
and behaviors of a set of objects
What is an Object?
Class Name
Attributes of Class
Operations/methods
of Class
Example of a Class Diagram
Video Rental System
visibility multiplicity class name
attributes methods
relationship
Visibility
of Attributes and Operations
• Relates to the level of information
hiding to be enforced
Visibility
of Attributes and Operations
Visibility Symbol Accessible To
Public + All objects within your system.
Provides
Patient Medical History
Association Relationship
• Role type shown by:
– drawing line between classes
– indicating with a plus sign before the
role name
Patient
+ primary insurance
carrier
Generalization Relationship
• Enables the analyst to create classes
that inherit attributes and operations of
other classes
• Represented by a-kind-of relationship
Generalization Relationship
Person
Employee Customer
Manager Engineer
Generalization Relationship
Employee
hireDate
receivePay
performWork
Manager Engineer
department certifications
bonus
hireEmployee analyze
promoteEmployee design
Generalization Relationship
Person
Employee Contractor
1 provides 0..1
Patient Medical History
Multiplicity
• Documents how many instances of a
class can be associated with one
instance of another class
1 provides 0..1
Patient Medical History
Multiplicity
• Denotes the minimum number..
maximum number of instances
Exactly one 1
Zero or more 0..* or 0..m
One or more 1..* or 1..m
Zero or one 0..1
Specified range 2..4
Multiple, disjoint ranges 1..3, 5
Class Diagram
• 2 approaches to deriving class
diagrams:
– from use cases and their scenarios
– from CRC cards
Deriving Class Diagram from
Use Cases and Scenarios
• Analyze the text in the use-case
descriptions and scenarios
Guidelines
for Analyzing Use Cases
• A common or improper noun implies
a class of objects
• A proper noun implies an instance of
a class
• A collective noun implies a class of
objects made up of groups of
instances of another class
Guidelines
for Analyzing Use Cases (2)
• An adjective implies an attribute of an
object
• A doing verb implies an operation
• A being verb implies a relationship
between an object and its class
• A having verb implies an aggregation
or association relationship
Brief Use Case format