Class Diagram
Class Diagram
Behavior Structure
Diagram Diagram
State
Activity Class Component Object
Machine
Diagram Diagram Diagram Diagram Diagram
Composite Deployment Package
Interaction Use Case
structure Diagram Diagram
Diagram Diagram Diagram
Profile
Diagram
Communication Interaction Sequence Timing
Diagram overview Diagram Diagram
Diagram
Class Diagram concept
The UML Class diagram is a graphical notation used to construct and
visualize object oriented systems.
Package State
Diagrams Diagrams
Class Diagrams components
• Classes
Attributes
Operations
• Class Relationships
Associations
Generalizations
• The name should be derived from the problem domain and should
be as unambiguous as possible.
Person
• The name should be a noun.
Attributes
Operations
Person
• The return type of a method is shown after the colon at the end of the
method signature.
Person
+ name : string
# address : string[*]
- birthdate : date
/ age : int
Operations
Visibility Access
• Association
• Aggregation
• Composition
• Generalization
Inheritance (or Generalization)
Represents an “is-a” relationship. << interface>>
Super class
Sub class
Association
A structural link between two peer classes.
Class1 Class1
Multiplicity
The number of objects that participate in the association.
Exactly one 1
Zero or more 0..*
One or more 1..*
Zero or one 0..1
Specified range 2..4
Aggregation
A special type of association.
It represents a “partof” relationship.
Class2 is part of Class1.
Class 1 Class 2
Class 1 Class 2
Class 1 Class 2
How to build a class diagram
Producing class diagrams involve the following iterative activities:
• Each line should contain the amount and the price of each product.
Example: Order - Associations
* 1
Order customer
Example: Order - Generalization
* 1
Order customer
Corporate personal
customer customer
Example: Order - More Associations
• We want our orders to be lined up product by product.
• Each line should contain the amount and the price of each product.
* 1
Order customer
1
*
Order Line Corporate personal
* customer customer
1 product
From Collaboration Diagram to
Class Diagram
View Employee List – Collaboration Diagram
From Sequence Diagram to Class
Diagram
View Employee List – Sequence Diagram
View Employee List _ Class
Diagram
From Collaboration Diagram to
Class Diagram
Pay Salary – Collaboration Diagram
From Sequence Diagram to Class
Diagram
Pay Salary– Sequence Diagram
Pay Salary _ Class Diagram
From Collaboration Diagram to
Class Diagram
Online Order– Collaboration Diagram
From Sequence Diagram to Class
Diagram
Online Order– Sequence Diagram
Online Order_ Class Diagram