Professional Documents
Culture Documents
Lec 8 & 9
Lec 8 & 9
PROGRAMMING (OOP)
LECTURE NO.08 & 09
MULTIPLE INHERITANCE
Mermaid
EXAMPLE – MULTIPLE
INHERITANCE
Woman Fish
Mermaid
EXAMPLE – MULTIPLE
INHERITANCE
Amphibious Vehicle
EXAMPLE – MULTIPLE
INHERITANCE
Vehicle
• Increased complexity
• Reduced understanding
• Duplicate features
PROBLEM – DUPLICATE
FEATURES
Woman Fish
eat eat
… …
Mermaid
Woman Fish
eat eat
… …
Mermaid
Invoke eat
eat
operation of
… desired class
PROBLEM – DUPLICATE FEATURES
(DIAMOND PROBLEM)
Vehicle
changeGear
• Class Association
• Inheritance
• Object Association
• Simple Association
• Composition
• Aggregation
SIMPLE ASSOCIATION
• w.r.t navigation
• One-way Association
• Two-way Association
lives-in
Ali House
1 1
• Ali lives in a
House
EXAMPLE – ASSOCIATION
drives
Ali Car
1 *
friend
Yasi Ali
1 1
r
• Yasir is a friend of
Ali
• Ali is a friend of
Yasir
BINARY ASSOCIATION
drives
Ali Car
1 *
Student 1
*
Teacher
*
Course
Project * *
Language
1
Person
1
Body
EXAMPLE – COMPOSITION OF
CHAIR
Back
1
Chair
2 1 4
Arm Seat Leg
COMPOSITION IS STRONGER
1
Cupboard
EXAMPLE – AGGREGATION
Garden * Plant
AGGREGATION IS WEAKER