SlideShare une entreprise Scribd logo
1  sur  19
Télécharger pour lire hors ligne
Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References
MULTIPLE INHERITANCE
Muhammad Adil Raja
Roaming Researchers, Inc.
cbna
April 20, 2015
Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References
OUTLINE I
INTRODUCTION
MULTIPLE INHERITANCE
NAME AMBIGUITY
COMMON ANCESTORS
INNER CLASSES
SUMMARY
REFERENCES
Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References
INTRODUCTION
• We will investigate some of the problems that can arize
when a language allows a child class to have multiple
parents.
• Name ambiguity.
• Impact on substitution.
• The Problem of Common Ancestors.
Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References
THE IDEALIZATION OF IS-A RELATIONSHIP
MESSAGE SYNTAX
• In one sense, the process of inheritance is a form of
categorization. A TextWindow is a type of Window, so
class TextWindow inherits from class Window.
• But in the real world, most objects can be categorized in a
variety of ways.
• The author of the textbook is:
• North American.
• Male.
• Professor.
• Parent.
• None of these are proper subsets of the other, and we
cannot make a single rooted inheritance hierarchy out of
them.
Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References
INHERITANCE AS COMBINATION
• Instead, real world objects are combinations of features
from different classification schemes, each category giving
some new insight into the whole:
• Author is North American, and
• Author is Male, and
• Author is a Professor, and
• Author is a Parent.
• Note that we have not lost the is-a relationship; it still
applies in each case.
Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References
CS EXAMPLE – COMPLEX NUMBERS
Two abstract classifications
• Magnitude – things that can be compared to each other.
• Number – things that can perform arithmetic.
Three specific classes
• Integer – comparable and arithmetic.
• Char – comparable but not arithmetic.
• Complex – arithmetic but not comparable.
Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References
POSSIBLE SOLUTIONS
1. Make Number subclass of Magnitude, but redefine
comparison operators in class complex to give error
message if used. (subclassing for limitation)
2. Don’t use inheritance at all – redefine all operators in all
classes. (flattening the inheritance tree).
3. Use part inheritance, but simulate others – use Number,
but have each number implement all relational operators.
4. Make Number and Magnitude independent, and have
Integer inherit from both. (multiple inheritance).
Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References
INHERITANCE AS A FORM OF COMBINATION
FIGURE : Inheritance.
Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References
ANOTHER EXAMPLE – WALKING MENUS
• A Menu is a structure charged with displaying itself when
selected by the user.
• A
• Menu maintains a collection of MenuItems.
• Each MenuItem knows how to respond when selected.
• A cascading menu is both a MenuItem and a Menu.
Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References
PROBLEM WITH MI – NAME AMBUITY
• What happens when same name is used in both parent
classes.
• A
• CardDeck knows how to draw a Card.
• A GraphicalItem knows how to draw an image on a
screen.
• A GraphicalCardDeck should be able to draw. which?
Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References
ONE SOLUTION – REDEFINITION
One solution is to redefine one or the other operation in the
child class.
REDEFINITION
class GraphicalCardDeck : public CardDeck , public GraphicalObject {
public :
virtual void draw ( ) { return CardDeck : : draw ( ) ; }
virtual void paint ( ) { GraphicalObject : : draw ( ) ; }
}
GraphicalCardDeck gcd ;
gcd−>draw ( ) ; / / selects CardDeck draw
gcd−>paint ( ) ; / / selects GraphicalObject draw
Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References
PROBLEM WITH REDEFINITION SOLUTION
• The redefinition solution is not without cost, however.
• Now what happens when we run up against the principle of
substitution?
REDEFINITION
GraphicalObject ∗ g = new GraphicalCardDeck ( ) ;
g−>draw ( ) ; / / opps , doing wrong method !
This problem can be mitigated, but the solution is complex and
not perfect.
Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References
OTHER APPROACHES TO NAME AMBIGUITY
• Other languages use different approaches to solving the
problem of ambiguous names.
• Eiffel uses the ability to rename features from the parent
class.
• A polymorphic variable accessing through the parents
name will access the renamed feature in the child.
• CLOS and Python resolve ambiguous names by the order
in which the parent classes are listed.
• The first occurrence of the name found in a systematic
search is the one selected.
Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References
MULTIPLE INHERITANCE OF INTERFACES
• Multiple inheritance of interfaces does not present the
same problem of name ambiguity as does multiple
inheritance of classes.
• Either the ambiguous methods in the parent classes have
different type signatures, in which case there is no
problem, or
• The ambiguous methods in the parent classes have the
same signature. Still no problem, since what is inherited is
only a specification, not an implementation.
• This is why Java permits multiple inheritance of interfaces,
not of classes. Nevertheless, C# does not permit the same
method name to be inherited from two parent interfaces.
Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References
INHERITANCE FROM COMMON ANCESTORS
• Another problem with MI occurs when parent classes have
a common root ancestor.
• Does the new object have one or two instances of the
ancestor?
FIGURE : Inheritance from common ancestors.
Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References
DATA FIELD IN COMMON ANCESTOR
• Imagine that the common ancestor declares a data
member. Should the child class have one copy of this data
field, or two?
• Both answers can be justified with examples.
• C++ gets around this by introducing the idea of a virtual
parent class.
• If your parent is virtual there is one copy, and if not there is
two.
• Not a perfect solution, and makes the language
complicated.
Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References
INNER CLASSES
• The ability to next classes in C++ and Java provides a
mechanism that is nearly equivalent to multiple
inheritance, without the semantic problems.
INNER CLASS
class Child extends ParentOne {
. . .
class InnerChild extends ParentTwo {
. . .
/ / can access both parents
}
}
Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References
SUMMARY
• In this chapter we have explored some of the problems that
arise of the concept of multiple inheritance.
• Name ambiguity.
• Impact on substitution.
• The Problem of Common Ancestors.
Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References
REFERENCES
• Images and content for developing these slides have been
taken from the follwoing book with the permission of the
author.
• An Introduction to Object Oriented Programming, Timothy
Budd.
• This presentation is developed using Beamer:
• Singapore, wolverine.

Contenu connexe

Tendances

Object Oriented Programming with C#
Object Oriented Programming with C#Object Oriented Programming with C#
Object Oriented Programming with C#foreverredpb
 
Java conditional statements
Java conditional statementsJava conditional statements
Java conditional statementsKuppusamy P
 
Concept of OOPS with real life examples
Concept of OOPS with real life examplesConcept of OOPS with real life examples
Concept of OOPS with real life examplesNeha Sharma
 
Applet skelton58
Applet skelton58Applet skelton58
Applet skelton58myrajendra
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Michelle Anne Meralpis
 
Constructors in java
Constructors in javaConstructors in java
Constructors in javasunilchute1
 
Inline Functions and Default arguments
Inline Functions and Default argumentsInline Functions and Default arguments
Inline Functions and Default argumentsNikhil Pandit
 
Operators in java presentation
Operators in java presentationOperators in java presentation
Operators in java presentationkunal kishore
 
Method Overloading In Java
Method Overloading In JavaMethod Overloading In Java
Method Overloading In JavaCharthaGaglani
 
Strings in Java
Strings in Java Strings in Java
Strings in Java Hitesh-Java
 
An Introduction to Programming in Java: Arrays
An Introduction to Programming in Java: ArraysAn Introduction to Programming in Java: Arrays
An Introduction to Programming in Java: ArraysMartin Chapman
 
Multiple inheritance in java3 (1).pptx
Multiple inheritance in java3 (1).pptxMultiple inheritance in java3 (1).pptx
Multiple inheritance in java3 (1).pptxRkGupta83
 
Object Oriented Programming In .Net
Object Oriented Programming In .NetObject Oriented Programming In .Net
Object Oriented Programming In .NetGreg Sohl
 
Polymorphism in java
Polymorphism in java Polymorphism in java
Polymorphism in java Janu Jahnavi
 

Tendances (20)

Object Oriented Programming with C#
Object Oriented Programming with C#Object Oriented Programming with C#
Object Oriented Programming with C#
 
Java conditional statements
Java conditional statementsJava conditional statements
Java conditional statements
 
Concept of OOPS with real life examples
Concept of OOPS with real life examplesConcept of OOPS with real life examples
Concept of OOPS with real life examples
 
Applet skelton58
Applet skelton58Applet skelton58
Applet skelton58
 
Java Programming
Java ProgrammingJava Programming
Java Programming
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Constructors in java
Constructors in javaConstructors in java
Constructors in java
 
Inline Functions and Default arguments
Inline Functions and Default argumentsInline Functions and Default arguments
Inline Functions and Default arguments
 
Operators in java presentation
Operators in java presentationOperators in java presentation
Operators in java presentation
 
Method Overloading In Java
Method Overloading In JavaMethod Overloading In Java
Method Overloading In Java
 
Strings in Java
Strings in Java Strings in Java
Strings in Java
 
An Introduction to Programming in Java: Arrays
An Introduction to Programming in Java: ArraysAn Introduction to Programming in Java: Arrays
An Introduction to Programming in Java: Arrays
 
Multiple inheritance in java3 (1).pptx
Multiple inheritance in java3 (1).pptxMultiple inheritance in java3 (1).pptx
Multiple inheritance in java3 (1).pptx
 
16 virtual function
16 virtual function16 virtual function
16 virtual function
 
Pseudocode
PseudocodePseudocode
Pseudocode
 
Polymorphism in java
Polymorphism in javaPolymorphism in java
Polymorphism in java
 
Object Oriented Programming In .Net
Object Oriented Programming In .NetObject Oriented Programming In .Net
Object Oriented Programming In .Net
 
File Handling In C++
File Handling In C++File Handling In C++
File Handling In C++
 
Polymorphism in java
Polymorphism in java Polymorphism in java
Polymorphism in java
 

En vedette

En vedette (19)

Inheritance in OOPS
Inheritance in OOPSInheritance in OOPS
Inheritance in OOPS
 
I2C programming with C and Arduino
I2C programming with C and ArduinoI2C programming with C and Arduino
I2C programming with C and Arduino
 
Protols used in bluetooth
Protols used in bluetoothProtols used in bluetooth
Protols used in bluetooth
 
Introduction to Embedded System
Introduction to Embedded SystemIntroduction to Embedded System
Introduction to Embedded System
 
Object-Oriented Design: Multiple inheritance (C++ and C#)
Object-Oriented Design: Multiple inheritance (C++ and C#)Object-Oriented Design: Multiple inheritance (C++ and C#)
Object-Oriented Design: Multiple inheritance (C++ and C#)
 
I2C Protocol
I2C ProtocolI2C Protocol
I2C Protocol
 
Compiler in System Programming/Code Optimization techniques in System Program...
Compiler in System Programming/Code Optimization techniques in System Program...Compiler in System Programming/Code Optimization techniques in System Program...
Compiler in System Programming/Code Optimization techniques in System Program...
 
Arm processor
Arm processorArm processor
Arm processor
 
Arm developement
Arm developementArm developement
Arm developement
 
Serial Peripheral Interface
Serial Peripheral InterfaceSerial Peripheral Interface
Serial Peripheral Interface
 
Embedded C - Optimization techniques
Embedded C - Optimization techniquesEmbedded C - Optimization techniques
Embedded C - Optimization techniques
 
SPI Protocol
SPI ProtocolSPI Protocol
SPI Protocol
 
Embedded C
Embedded CEmbedded C
Embedded C
 
I2C Bus (Inter-Integrated Circuit)
I2C Bus (Inter-Integrated Circuit)I2C Bus (Inter-Integrated Circuit)
I2C Bus (Inter-Integrated Circuit)
 
Embedded C - Lecture 1
Embedded C - Lecture 1Embedded C - Lecture 1
Embedded C - Lecture 1
 
Serial peripheral interface
Serial peripheral interfaceSerial peripheral interface
Serial peripheral interface
 
Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)
 
Code Optimization
Code OptimizationCode Optimization
Code Optimization
 
Iot
IotIot
Iot
 

Similaire à Problems of Multiple Inheritance in Object Oriented Programming

Similaire à Problems of Multiple Inheritance in Object Oriented Programming (20)

Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Inheritance and Substitution
Inheritance and SubstitutionInheritance and Substitution
Inheritance and Substitution
 
Java programming -Object-Oriented Thinking- Inheritance
Java programming -Object-Oriented Thinking- InheritanceJava programming -Object-Oriented Thinking- Inheritance
Java programming -Object-Oriented Thinking- Inheritance
 
Unit 3
Unit 3Unit 3
Unit 3
 
INHERITANCE-Oopc ppt-ta4
INHERITANCE-Oopc ppt-ta4INHERITANCE-Oopc ppt-ta4
INHERITANCE-Oopc ppt-ta4
 
SAD04 - Inheritance
SAD04 - InheritanceSAD04 - Inheritance
SAD04 - Inheritance
 
SKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPTSKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPT
 
Java_notes.ppt
Java_notes.pptJava_notes.ppt
Java_notes.ppt
 
How would you implement multiple inheritance in java
How would you implement multiple inheritance in javaHow would you implement multiple inheritance in java
How would you implement multiple inheritance in java
 
Java OOPS Concept
Java OOPS ConceptJava OOPS Concept
Java OOPS Concept
 
Concepts of oop1
Concepts of oop1Concepts of oop1
Concepts of oop1
 
Introduction to oop and java fundamentals
Introduction to oop and java fundamentalsIntroduction to oop and java fundamentals
Introduction to oop and java fundamentals
 
2CPP07 - Inheritance
2CPP07 - Inheritance2CPP07 - Inheritance
2CPP07 - Inheritance
 
Multiple inheritance possible in Java
Multiple inheritance possible in JavaMultiple inheritance possible in Java
Multiple inheritance possible in Java
 
Multiple inheritance
Multiple inheritanceMultiple inheritance
Multiple inheritance
 
Lo15
Lo15Lo15
Lo15
 
OO relationships between classes
OO relationships between classesOO relationships between classes
OO relationships between classes
 
Inheritance
InheritanceInheritance
Inheritance
 
04 inheritance
04 inheritance04 inheritance
04 inheritance
 
Inheritance.pptx
Inheritance.pptxInheritance.pptx
Inheritance.pptx
 

Plus de adil raja

A Software Requirements Specification
A Software Requirements SpecificationA Software Requirements Specification
A Software Requirements Specificationadil raja
 
NUAV - A Testbed for Development of Autonomous Unmanned Aerial Vehicles
NUAV - A Testbed for Development of Autonomous Unmanned Aerial VehiclesNUAV - A Testbed for Development of Autonomous Unmanned Aerial Vehicles
NUAV - A Testbed for Development of Autonomous Unmanned Aerial Vehiclesadil raja
 
DevOps Demystified
DevOps DemystifiedDevOps Demystified
DevOps Demystifiedadil raja
 
On Research (And Development)
On Research (And Development)On Research (And Development)
On Research (And Development)adil raja
 
Simulators as Drivers of Cutting Edge Research
Simulators as Drivers of Cutting Edge ResearchSimulators as Drivers of Cutting Edge Research
Simulators as Drivers of Cutting Edge Researchadil raja
 
The Knock Knock Protocol
The Knock Knock ProtocolThe Knock Knock Protocol
The Knock Knock Protocoladil raja
 
File Transfer Through Sockets
File Transfer Through SocketsFile Transfer Through Sockets
File Transfer Through Socketsadil raja
 
Remote Command Execution
Remote Command ExecutionRemote Command Execution
Remote Command Executionadil raja
 
CMM Level 3 Assessment of Xavor Pakistan
CMM Level 3 Assessment of Xavor PakistanCMM Level 3 Assessment of Xavor Pakistan
CMM Level 3 Assessment of Xavor Pakistanadil raja
 
Data Warehousing
Data WarehousingData Warehousing
Data Warehousingadil raja
 
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...adil raja
 
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...adil raja
 
Real-Time Non-Intrusive Speech Quality Estimation for VoIP
Real-Time Non-Intrusive Speech Quality Estimation for VoIPReal-Time Non-Intrusive Speech Quality Estimation for VoIP
Real-Time Non-Intrusive Speech Quality Estimation for VoIPadil raja
 
ULMAN GUI Specifications
ULMAN GUI SpecificationsULMAN GUI Specifications
ULMAN GUI Specificationsadil raja
 
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...adil raja
 
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...adil raja
 

Plus de adil raja (20)

ANNs.pdf
ANNs.pdfANNs.pdf
ANNs.pdf
 
A Software Requirements Specification
A Software Requirements SpecificationA Software Requirements Specification
A Software Requirements Specification
 
NUAV - A Testbed for Development of Autonomous Unmanned Aerial Vehicles
NUAV - A Testbed for Development of Autonomous Unmanned Aerial VehiclesNUAV - A Testbed for Development of Autonomous Unmanned Aerial Vehicles
NUAV - A Testbed for Development of Autonomous Unmanned Aerial Vehicles
 
DevOps Demystified
DevOps DemystifiedDevOps Demystified
DevOps Demystified
 
On Research (And Development)
On Research (And Development)On Research (And Development)
On Research (And Development)
 
Simulators as Drivers of Cutting Edge Research
Simulators as Drivers of Cutting Edge ResearchSimulators as Drivers of Cutting Edge Research
Simulators as Drivers of Cutting Edge Research
 
The Knock Knock Protocol
The Knock Knock ProtocolThe Knock Knock Protocol
The Knock Knock Protocol
 
File Transfer Through Sockets
File Transfer Through SocketsFile Transfer Through Sockets
File Transfer Through Sockets
 
Remote Command Execution
Remote Command ExecutionRemote Command Execution
Remote Command Execution
 
Thesis
ThesisThesis
Thesis
 
CMM Level 3 Assessment of Xavor Pakistan
CMM Level 3 Assessment of Xavor PakistanCMM Level 3 Assessment of Xavor Pakistan
CMM Level 3 Assessment of Xavor Pakistan
 
Data Warehousing
Data WarehousingData Warehousing
Data Warehousing
 
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
 
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
Implementation of a Non-Intrusive Speech Quality Assessment Tool on a Mid-Net...
 
Real-Time Non-Intrusive Speech Quality Estimation for VoIP
Real-Time Non-Intrusive Speech Quality Estimation for VoIPReal-Time Non-Intrusive Speech Quality Estimation for VoIP
Real-Time Non-Intrusive Speech Quality Estimation for VoIP
 
VoIP
VoIPVoIP
VoIP
 
ULMAN GUI Specifications
ULMAN GUI SpecificationsULMAN GUI Specifications
ULMAN GUI Specifications
 
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
 
ULMAN-GUI
ULMAN-GUIULMAN-GUI
ULMAN-GUI
 
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
Modeling the Effect of Packet Loss on Speech Quality: Genetic Programming Bas...
 

Dernier

Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
buds n tech IT solutions
buds n  tech IT                solutionsbuds n  tech IT                solutions
buds n tech IT solutionsmonugehlot87
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?Watsoo Telematics
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 

Dernier (20)

Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
buds n tech IT solutions
buds n  tech IT                solutionsbuds n  tech IT                solutions
buds n tech IT solutions
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 

Problems of Multiple Inheritance in Object Oriented Programming

  • 1. Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References MULTIPLE INHERITANCE Muhammad Adil Raja Roaming Researchers, Inc. cbna April 20, 2015
  • 2. Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References OUTLINE I INTRODUCTION MULTIPLE INHERITANCE NAME AMBIGUITY COMMON ANCESTORS INNER CLASSES SUMMARY REFERENCES
  • 3. Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References INTRODUCTION • We will investigate some of the problems that can arize when a language allows a child class to have multiple parents. • Name ambiguity. • Impact on substitution. • The Problem of Common Ancestors.
  • 4. Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References THE IDEALIZATION OF IS-A RELATIONSHIP MESSAGE SYNTAX • In one sense, the process of inheritance is a form of categorization. A TextWindow is a type of Window, so class TextWindow inherits from class Window. • But in the real world, most objects can be categorized in a variety of ways. • The author of the textbook is: • North American. • Male. • Professor. • Parent. • None of these are proper subsets of the other, and we cannot make a single rooted inheritance hierarchy out of them.
  • 5. Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References INHERITANCE AS COMBINATION • Instead, real world objects are combinations of features from different classification schemes, each category giving some new insight into the whole: • Author is North American, and • Author is Male, and • Author is a Professor, and • Author is a Parent. • Note that we have not lost the is-a relationship; it still applies in each case.
  • 6. Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References CS EXAMPLE – COMPLEX NUMBERS Two abstract classifications • Magnitude – things that can be compared to each other. • Number – things that can perform arithmetic. Three specific classes • Integer – comparable and arithmetic. • Char – comparable but not arithmetic. • Complex – arithmetic but not comparable.
  • 7. Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References POSSIBLE SOLUTIONS 1. Make Number subclass of Magnitude, but redefine comparison operators in class complex to give error message if used. (subclassing for limitation) 2. Don’t use inheritance at all – redefine all operators in all classes. (flattening the inheritance tree). 3. Use part inheritance, but simulate others – use Number, but have each number implement all relational operators. 4. Make Number and Magnitude independent, and have Integer inherit from both. (multiple inheritance).
  • 8. Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References INHERITANCE AS A FORM OF COMBINATION FIGURE : Inheritance.
  • 9. Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References ANOTHER EXAMPLE – WALKING MENUS • A Menu is a structure charged with displaying itself when selected by the user. • A • Menu maintains a collection of MenuItems. • Each MenuItem knows how to respond when selected. • A cascading menu is both a MenuItem and a Menu.
  • 10. Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References PROBLEM WITH MI – NAME AMBUITY • What happens when same name is used in both parent classes. • A • CardDeck knows how to draw a Card. • A GraphicalItem knows how to draw an image on a screen. • A GraphicalCardDeck should be able to draw. which?
  • 11. Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References ONE SOLUTION – REDEFINITION One solution is to redefine one or the other operation in the child class. REDEFINITION class GraphicalCardDeck : public CardDeck , public GraphicalObject { public : virtual void draw ( ) { return CardDeck : : draw ( ) ; } virtual void paint ( ) { GraphicalObject : : draw ( ) ; } } GraphicalCardDeck gcd ; gcd−>draw ( ) ; / / selects CardDeck draw gcd−>paint ( ) ; / / selects GraphicalObject draw
  • 12. Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References PROBLEM WITH REDEFINITION SOLUTION • The redefinition solution is not without cost, however. • Now what happens when we run up against the principle of substitution? REDEFINITION GraphicalObject ∗ g = new GraphicalCardDeck ( ) ; g−>draw ( ) ; / / opps , doing wrong method ! This problem can be mitigated, but the solution is complex and not perfect.
  • 13. Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References OTHER APPROACHES TO NAME AMBIGUITY • Other languages use different approaches to solving the problem of ambiguous names. • Eiffel uses the ability to rename features from the parent class. • A polymorphic variable accessing through the parents name will access the renamed feature in the child. • CLOS and Python resolve ambiguous names by the order in which the parent classes are listed. • The first occurrence of the name found in a systematic search is the one selected.
  • 14. Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References MULTIPLE INHERITANCE OF INTERFACES • Multiple inheritance of interfaces does not present the same problem of name ambiguity as does multiple inheritance of classes. • Either the ambiguous methods in the parent classes have different type signatures, in which case there is no problem, or • The ambiguous methods in the parent classes have the same signature. Still no problem, since what is inherited is only a specification, not an implementation. • This is why Java permits multiple inheritance of interfaces, not of classes. Nevertheless, C# does not permit the same method name to be inherited from two parent interfaces.
  • 15. Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References INHERITANCE FROM COMMON ANCESTORS • Another problem with MI occurs when parent classes have a common root ancestor. • Does the new object have one or two instances of the ancestor? FIGURE : Inheritance from common ancestors.
  • 16. Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References DATA FIELD IN COMMON ANCESTOR • Imagine that the common ancestor declares a data member. Should the child class have one copy of this data field, or two? • Both answers can be justified with examples. • C++ gets around this by introducing the idea of a virtual parent class. • If your parent is virtual there is one copy, and if not there is two. • Not a perfect solution, and makes the language complicated.
  • 17. Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References INNER CLASSES • The ability to next classes in C++ and Java provides a mechanism that is nearly equivalent to multiple inheritance, without the semantic problems. INNER CLASS class Child extends ParentOne { . . . class InnerChild extends ParentTwo { . . . / / can access both parents } }
  • 18. Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References SUMMARY • In this chapter we have explored some of the problems that arise of the concept of multiple inheritance. • Name ambiguity. • Impact on substitution. • The Problem of Common Ancestors.
  • 19. Introduction Multiple Inheritance Name Ambiguity Common Ancestors Inner Classes Summary References REFERENCES • Images and content for developing these slides have been taken from the follwoing book with the permission of the author. • An Introduction to Object Oriented Programming, Timothy Budd. • This presentation is developed using Beamer: • Singapore, wolverine.