Lecture 11-UML Basics Inheritance Association, Aggregation, Composition
Lecture 11-UML Basics Inheritance Association, Aggregation, Composition
Mohammad Hasan
Assistant Professor & Adjunct Faculty
Department of CSE, NDUB
Contents
UML Basics
- Generalization (Inheritance) – IS-A Relationship
- Association
- Aggregation
- Composition – HAS-A Relationship
2
Topic - 1 : Inheritance (Generalization)
3
SubClass1 and SubClass2 are specializations of SuperClass.
IS-A relationship
Bank Human
Super // Generalization
extends extends
DBBL Boy
Sub // Specialization
4
Topic - 2 : Association
5
Two types of Association
Unary Association: Class A has Class B; But Class B does not have Class A
Customer buys
Product
>
7
Unary Association
Two types and Binary Association
of Association
2. Binary Association
Student Teacher
8
Unary Association
Two types and Binary Association
of Association
2. Binary Association (Solved by Association Class)
Student Teacher
AssociationClass
9
Topic - 3 : Aggregation and Composition
[Whole/Part Relationship]
10
3.1: Aggregation
Specified form of Association
Whole/Part Relationship
A B
Whole Part
Car Engine
11
Whole Part
3.2: Composition
Specified (Stronger) form of Association
Whole/Part Relationship
A B
Whole Part
Whole Part
The figure below shows the three types of association connectors:
association, aggregation and composition
13
UML Notation
Inheritance
14
Example - 1
15
Example – 2: Description to UML
Volvo is a Car.
Every car has model and company of type string.
Volvo has price of type double, productionYear and registrationNumber of type string.
Volvo also has Engine and DashBoard.
Engine has capacity of type double.
DashBoard has size of type double.
Car provides drive and stop as abstract service or method of type void.
Volvo also provides changeFuel and checkBattery service or method of type void.
16
Example – 2: Description to UML
Volvo is a Car.
Every car has model and company of type string.
Volvo has price of type double, productionYear and registrationNumber of type
string.
Volvo also has Engine and DashBoard.
Engine has capacity of type double.
DashBoard has size of type double.
Car provides drive and stop as abstract service or method of type void.
Volvo also provides changeFuel and checkBattery service or method of type void.
17
Solution of Example – 2: Description to UML
• Volvo is a Car.
Car
• Every car has model and company of
#model : String
type string.
#company: String
• Volvo has price of type double,
productionYear and + drive () : void
registrationNumber of type string. + stop () : void
20
Thank you!
21