5.1 Class Diagram in UML
5.1 Class Diagram in UML
5.1 Class Diagram in UML
BRAC University
What is a Class?
operations
Person
An attribute is a named property of a
class that describes the object being
name : String
address : Address modeled.
birthdate : Date In the class diagram, attributes appear in
ssn : Id the second compartment just below the
name-compartment.
Person
name : String
address : Address
birthdate : Date
ssn : Id
PhoneBook
You can specify an operation by stating its signature: listing the name, type, and default
value of all parameters, and, in the case of functions, a return type.
name : String
birthdate : Date
Person ssn : Id
Class Name
Attributes of Class
Operations/methods
of Class
Visibility
of Attributes and Operations
Relatesto the level of information hiding
to be enforced
Visibility
of Attributes and Operations
Visibility Symbol Accessible To
Public + All objects within your system.
Person
+ eat ()
+ sleep ()
Provides
Patient Medical History
Association Relationships
If two classes in a model need to communicate with each other, there must be link
between them.
Student Instructor
Student Instructor
1..*
The example indicates that every Instructor has one or more Students:
Student Instructor
1..*
+ primary insurance
carrier
Aggregation Relationship
Specialized form of association in which a
whole is related to its part(s)
Represented by a-part-of relationship
Specifies a whole-part relationship
between an aggregate (a whole) and a
constituent part, where the part can exist
independently from the aggregate.
Aggregation Relationship
Aggregations
are denoted by a hollow-
diamond adornment on the association.
Engine
Car
Transmission
Composition Relationship
A composition indicates a strong ownership and
coincident lifetime of parts by the whole (i.e., they
live and die as a whole). Compositions are denoted by
a filled-diamond adornment on the association
Scrollbar
Window Titlebar
Menu
Generalization Relationship
Person
A generalization connects a subclass
to its superclass. It denotes an
inheritance of attributes and behavior
from the superclass to the subclass and
indicates a specialization in the subclass
of the more general superclass.
Student
Student Employee
TeachingAssistant
Person
Employee Customer
Manager Engineer
Generalization Relationship
Employee
hireDate
receivePay
performWork
Manager Engineer
department certifications
bonus
hireEmployee analyze
promoteEmployee design
Multiplicity
Documents how many instances of a class
can be associated with one instance of
another class