SlideShare ist ein Scribd-Unternehmen logo
1 von 11
Downloaden Sie, um offline zu lesen
Introduction Forms of Polymorphism Summary References
POLYMORPHISM AND SOFTWARE REUSE
Muhammad Adil Raja
Roaming Researchers, Inc.
cbna
April 20, 2015
Introduction Forms of Polymorphism Summary References
OUTLINE I
INTRODUCTION
FORMS OF POLYMORPHISM
SUMMARY
REFERENCES
Introduction Forms of Polymorphism Summary References
INTRODUCTION
• In this chapter and the four that follow we will start to
investigate polymorphism, as it is found in many forms in
object-oriented languages.
• In this chapter we will outline the four major types of
polymorphism, then explore them in more detail in the later
chapters.
• The different mechanisms each have the same goal of
encouraging software reuse, facilitating ease of
understanding and speeding application development.
Introduction Forms of Polymorphism Summary References
DEFINITION OF POLYMORPHISM
MESSAGE SYNTAX
• Polymorphous: Having, or assuming, various forms,
characters, or styles.
• From greek routes, poly = many, and Morphos = form
(Morphus was the greek god of sleep, who could assume
many forms, and from which we derive the name
Morphine, among other things).
• A polymorphic compound can crystalize in many forms,
such as carbon, which can be graphite, diamonds, or
fullerenes.
• In programming languages, used for a variety of different
mechanisms.
• Usage of the term is confused by the fact that it means
something slightly different in the functional programming
community than it does in the OO world.)
Introduction Forms of Polymorphism Summary References
FORMS OF POLYMORPHISM IN OOP
• There are four major forms of polymorphism in
object-oriented languages:
• Overloading (ad hoc polymorphism) – one name that
refers to two or more different implementations.
• Overriding (inclusion polymorphism) – A child class
redefining a method inherited from a parent class.
• The Polymorphic Variable (assignment polymorphism) – A
variable that can hold different types of values during the
course of execution.
• It is called Pure Polymorphism when a polymorphic
variable is used as a parameter.
• Generics (or Templates) – A way of creating general tools
or classes by parameterizing on types.
Introduction Forms of Polymorphism Summary References
TWO FORMS OF SOFTWARE REUSE
• One of the major goals of OOP is software reuse.
• We can illustrate this by considering two different
approaches to reuse:
• Inheritance – the is-a relationship.
• Composition – the has-a relationship.
• We do this by considering an example problem that could
use either mechanism.
Introduction Forms of Polymorphism Summary References
EXAMPLE – BUILDING SETS FROM LISTS
• Suppose we have already a List data type with the
following behavior:
• Want to build the Set data type (elements are unique).
LISTS
class L i s t {
public :
void add ( int ) ;
int includes ( int ) ;
void remove ( int ) ;
int firstElement ( ) ;
} ;
Introduction Forms of Polymorphism Summary References
USING INHERITANCE
Only need specify what is new - the addition method.
Everything else is given for free.
INHERITANCE
class Set : public L i s t {
public :
void add ( int ) ;
} ;
void Set : : add ( int x )
{
i f ( ! includes ( x ) ) / / only include i f not already there
L i s t : : add ( x ) ;
}
Introduction Forms of Polymorphism Summary References
USING COMPOSITION
• Everything must be redefined, but implementation can
make use of the list data structure.
COMPOSITION
class Set {
public :
void add ( int ) ;
int includes ( int ) ;
void remove ( int ) ;
int firstElement ( ) ;
private :
L i s t data ;
} ;
void Set : : add ( int x )
{
i f ( ! data . includes ( x ) )
data . add ( x ) ;
}
int Set : : includes ( int x )
{ return data . includes ( x ) ; }
void Set : : remove ( int x )
{ data . remove ( x ) ; }
int Set : : firstElement ( )
{ return data . firstElement ( ) ; }
Introduction Forms of Polymorphism Summary References
ADVANTAGES AND DISADVANTAGES OF EACH
MECHANISM
• Composition is simpler, and clearly indicates what
operations are provided.
• Inheritance makes for shorter code, possibly increased
functionality, but makes it more difficult to understand what
behavior is being provided.
• Inheritance may open to the door for unintended usage, by
means of unintended inheritance of behavior.
• Easier to change underlying details using composition (i.e.,
change the data representation).
• Inheritance may permit polymorphism.
• Understandability is a toss-up, each has different
complexity issues (size versus inheritance tree depth).
• Very small execution time advantage for inheritance.
Introduction Forms of Polymorphism 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, beaver.

Weitere ähnliche Inhalte

Was ist angesagt?

Java interfaces
Java interfacesJava interfaces
Java interfacesjehan1987
 
Polymorphism in java
Polymorphism in javaPolymorphism in java
Polymorphism in javasureshraj43
 
‫‫Chapter4 Polymorphism
‫‫Chapter4 Polymorphism‫‫Chapter4 Polymorphism
‫‫Chapter4 PolymorphismMahmoud Alfarra
 
Polymorphism in java
Polymorphism in java Polymorphism in java
Polymorphism in java Janu Jahnavi
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented ProgrammingHaris Bin Zahid
 
Polymorphism In Java
Polymorphism In JavaPolymorphism In Java
Polymorphism In JavaSpotle.ai
 
Object as function argument , friend and static function by shahzad younas
Object as function argument , friend and static function by shahzad younasObject as function argument , friend and static function by shahzad younas
Object as function argument , friend and static function by shahzad younasShahzad Younas
 
Abstract Class & Abstract Method in Core Java
Abstract Class & Abstract Method in Core JavaAbstract Class & Abstract Method in Core Java
Abstract Class & Abstract Method in Core JavaMOHIT AGARWAL
 
البرمجة الهدفية بلغة جافا - مصفوفة الكائنات
البرمجة الهدفية  بلغة جافا - مصفوفة الكائناتالبرمجة الهدفية  بلغة جافا - مصفوفة الكائنات
البرمجة الهدفية بلغة جافا - مصفوفة الكائناتMahmoud Alfarra
 
‫Object Oriented Programming_Lecture 3
‫Object Oriented Programming_Lecture 3‫Object Oriented Programming_Lecture 3
‫Object Oriented Programming_Lecture 3Mahmoud Alfarra
 
Friends function and_classes
Friends function and_classesFriends function and_classes
Friends function and_classesasadsardar
 
Abstract Class Presentation
Abstract Class PresentationAbstract Class Presentation
Abstract Class Presentationtigerwarn
 
Inheritance and Polymorphism in java simple and clear
Inheritance and Polymorphism in java simple and clear Inheritance and Polymorphism in java simple and clear
Inheritance and Polymorphism in java simple and clear ASHNA nadhm
 
Unit 2-data types,Variables,Operators,Conitionals,loops and arrays
Unit 2-data types,Variables,Operators,Conitionals,loops and arraysUnit 2-data types,Variables,Operators,Conitionals,loops and arrays
Unit 2-data types,Variables,Operators,Conitionals,loops and arraysDevaKumari Vijay
 

Was ist angesagt? (20)

Java interfaces
Java interfacesJava interfaces
Java interfaces
 
‫Chapter3 inheritance
‫Chapter3 inheritance‫Chapter3 inheritance
‫Chapter3 inheritance
 
Polymorphism in java
Polymorphism in javaPolymorphism in java
Polymorphism in java
 
‫‫Chapter4 Polymorphism
‫‫Chapter4 Polymorphism‫‫Chapter4 Polymorphism
‫‫Chapter4 Polymorphism
 
Polymorphism in java
Polymorphism in java Polymorphism in java
Polymorphism in java
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
 
Inner classes in java
Inner classes in javaInner classes in java
Inner classes in java
 
Polymorphism In Java
Polymorphism In JavaPolymorphism In Java
Polymorphism In Java
 
Object as function argument , friend and static function by shahzad younas
Object as function argument , friend and static function by shahzad younasObject as function argument , friend and static function by shahzad younas
Object as function argument , friend and static function by shahzad younas
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Abstract Class & Abstract Method in Core Java
Abstract Class & Abstract Method in Core JavaAbstract Class & Abstract Method in Core Java
Abstract Class & Abstract Method in Core Java
 
Java interface
Java interfaceJava interface
Java interface
 
البرمجة الهدفية بلغة جافا - مصفوفة الكائنات
البرمجة الهدفية  بلغة جافا - مصفوفة الكائناتالبرمجة الهدفية  بلغة جافا - مصفوفة الكائنات
البرمجة الهدفية بلغة جافا - مصفوفة الكائنات
 
OOP java
OOP javaOOP java
OOP java
 
‫Object Oriented Programming_Lecture 3
‫Object Oriented Programming_Lecture 3‫Object Oriented Programming_Lecture 3
‫Object Oriented Programming_Lecture 3
 
Friends function and_classes
Friends function and_classesFriends function and_classes
Friends function and_classes
 
Abstract Class Presentation
Abstract Class PresentationAbstract Class Presentation
Abstract Class Presentation
 
Inheritance and Polymorphism in java simple and clear
Inheritance and Polymorphism in java simple and clear Inheritance and Polymorphism in java simple and clear
Inheritance and Polymorphism in java simple and clear
 
Unit 2-data types,Variables,Operators,Conitionals,loops and arrays
Unit 2-data types,Variables,Operators,Conitionals,loops and arraysUnit 2-data types,Variables,Operators,Conitionals,loops and arrays
Unit 2-data types,Variables,Operators,Conitionals,loops and arrays
 
Interface in java
Interface in javaInterface in java
Interface in java
 

Andere mochten auch

Classes And Methods
Classes And MethodsClasses And Methods
Classes And Methodsadil raja
 
12 couplingand cohesion-student
12 couplingand cohesion-student12 couplingand cohesion-student
12 couplingand cohesion-studentrandhirlpu
 
Universal Declarative Services
Universal Declarative ServicesUniversal Declarative Services
Universal Declarative Servicesschemouil
 
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...cprogrammings
 
Data structure and algorithms in c++
Data structure and algorithms in c++Data structure and algorithms in c++
Data structure and algorithms in c++Karmjeet Chahal
 
The Physical Layer
The Physical LayerThe Physical Layer
The Physical Layeradil raja
 
Iterator - a powerful but underappreciated design pattern
Iterator - a powerful but underappreciated design patternIterator - a powerful but underappreciated design pattern
Iterator - a powerful but underappreciated design patternNitin Bhide
 
XKE - Programming Paradigms & Constructs
XKE - Programming Paradigms & ConstructsXKE - Programming Paradigms & Constructs
XKE - Programming Paradigms & ConstructsNicolas Demengel
 
The Data Link Layer
The Data Link LayerThe Data Link Layer
The Data Link Layeradil raja
 
Hashing and Hash Tables
Hashing and Hash TablesHashing and Hash Tables
Hashing and Hash Tablesadil raja
 
C++: inheritance, composition, polymorphism
C++: inheritance, composition, polymorphismC++: inheritance, composition, polymorphism
C++: inheritance, composition, polymorphismJussi Pohjolainen
 
The Network Layer
The Network LayerThe Network Layer
The Network Layeradil raja
 

Andere mochten auch (20)

04 design concepts_n_principles
04 design concepts_n_principles04 design concepts_n_principles
04 design concepts_n_principles
 
Association agggregation and composition
Association agggregation and compositionAssociation agggregation and composition
Association agggregation and composition
 
Classes And Methods
Classes And MethodsClasses And Methods
Classes And Methods
 
12 couplingand cohesion-student
12 couplingand cohesion-student12 couplingand cohesion-student
12 couplingand cohesion-student
 
Universal Declarative Services
Universal Declarative ServicesUniversal Declarative Services
Universal Declarative Services
 
Syntax part 6
Syntax part 6Syntax part 6
Syntax part 6
 
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
 
Data structure and algorithms in c++
Data structure and algorithms in c++Data structure and algorithms in c++
Data structure and algorithms in c++
 
The Physical Layer
The Physical LayerThe Physical Layer
The Physical Layer
 
Iterator - a powerful but underappreciated design pattern
Iterator - a powerful but underappreciated design patternIterator - a powerful but underappreciated design pattern
Iterator - a powerful but underappreciated design pattern
 
C++ Inheritance
C++ InheritanceC++ Inheritance
C++ Inheritance
 
XKE - Programming Paradigms & Constructs
XKE - Programming Paradigms & ConstructsXKE - Programming Paradigms & Constructs
XKE - Programming Paradigms & Constructs
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
The Data Link Layer
The Data Link LayerThe Data Link Layer
The Data Link Layer
 
Hashing and Hash Tables
Hashing and Hash TablesHashing and Hash Tables
Hashing and Hash Tables
 
WSO2 Complex Event Processor
WSO2 Complex Event ProcessorWSO2 Complex Event Processor
WSO2 Complex Event Processor
 
C++: inheritance, composition, polymorphism
C++: inheritance, composition, polymorphismC++: inheritance, composition, polymorphism
C++: inheritance, composition, polymorphism
 
Cohesion and coherence
Cohesion and coherenceCohesion and coherence
Cohesion and coherence
 
Cohesion & Coupling
Cohesion & Coupling Cohesion & Coupling
Cohesion & Coupling
 
The Network Layer
The Network LayerThe Network Layer
The Network Layer
 

Ähnlich wie Polymorphism Forms Software Reuse

Introduction to oop
Introduction to oopIntroduction to oop
Introduction to oopcolleges
 
Object-Oriented Polymorphism Unleashed
Object-Oriented Polymorphism UnleashedObject-Oriented Polymorphism Unleashed
Object-Oriented Polymorphism UnleashedNaresh Chintalcheru
 
Object Oriented Programming (OOP) Introduction
Object Oriented Programming (OOP) IntroductionObject Oriented Programming (OOP) Introduction
Object Oriented Programming (OOP) IntroductionSamuelAnsong6
 
OOPS – General Understanding in .NET
OOPS – General Understanding in .NETOOPS – General Understanding in .NET
OOPS – General Understanding in .NETSabith Byari
 
Pi j3.2 polymorphism
Pi j3.2 polymorphismPi j3.2 polymorphism
Pi j3.2 polymorphismmcollison
 
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...Akhil Mittal
 
oopsinvb-191021101327.pdf
oopsinvb-191021101327.pdfoopsinvb-191021101327.pdf
oopsinvb-191021101327.pdfJP Chicano
 
Implementing polymorphism
Implementing polymorphismImplementing polymorphism
Implementing polymorphismrajshreemuthiah
 
Object Oriented Programming Overview for the PeopleSoft Developer
Object Oriented Programming Overview for the PeopleSoft DeveloperObject Oriented Programming Overview for the PeopleSoft Developer
Object Oriented Programming Overview for the PeopleSoft DeveloperLee Greffin
 
pythontraining-201jn026043638.pptx
pythontraining-201jn026043638.pptxpythontraining-201jn026043638.pptx
pythontraining-201jn026043638.pptxRohitKumar639388
 
python interview prep question , 52 questions
python interview prep question , 52 questionspython interview prep question , 52 questions
python interview prep question , 52 questionsgokul174578
 

Ähnlich wie Polymorphism Forms Software Reuse (20)

Introduction to oop
Introduction to oopIntroduction to oop
Introduction to oop
 
Object-Oriented Polymorphism Unleashed
Object-Oriented Polymorphism UnleashedObject-Oriented Polymorphism Unleashed
Object-Oriented Polymorphism Unleashed
 
C++ first s lide
C++ first s lideC++ first s lide
C++ first s lide
 
Object Oriented Programming (OOP) Introduction
Object Oriented Programming (OOP) IntroductionObject Oriented Programming (OOP) Introduction
Object Oriented Programming (OOP) Introduction
 
OOPS – General Understanding in .NET
OOPS – General Understanding in .NETOOPS – General Understanding in .NET
OOPS – General Understanding in .NET
 
Pi j3.2 polymorphism
Pi j3.2 polymorphismPi j3.2 polymorphism
Pi j3.2 polymorphism
 
Lecture 18
Lecture 18Lecture 18
Lecture 18
 
Python training
Python trainingPython training
Python training
 
Python Concepts
Python ConceptsPython Concepts
Python Concepts
 
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...
Diving in OOP (Day 1) : Polymorphism and Inheritance (Early Binding/Compile T...
 
Phython presentation
Phython presentationPhython presentation
Phython presentation
 
Python training
Python trainingPython training
Python training
 
oopsinvb-191021101327.pdf
oopsinvb-191021101327.pdfoopsinvb-191021101327.pdf
oopsinvb-191021101327.pdf
 
Oops in vb
Oops in vbOops in vb
Oops in vb
 
Implementing polymorphism
Implementing polymorphismImplementing polymorphism
Implementing polymorphism
 
Object Oriented Programming Overview for the PeopleSoft Developer
Object Oriented Programming Overview for the PeopleSoft DeveloperObject Oriented Programming Overview for the PeopleSoft Developer
Object Oriented Programming Overview for the PeopleSoft Developer
 
Interfaces in java
Interfaces in javaInterfaces in java
Interfaces in java
 
pythontraining-201jn026043638.pptx
pythontraining-201jn026043638.pptxpythontraining-201jn026043638.pptx
pythontraining-201jn026043638.pptx
 
Oops slide
Oops slide Oops slide
Oops slide
 
python interview prep question , 52 questions
python interview prep question , 52 questionspython interview prep question , 52 questions
python interview prep question , 52 questions
 

Mehr von 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
 

Mehr von 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...
 

Kürzlich hochgeladen

5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....ShaimaaMohamedGalal
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
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
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 

Kürzlich hochgeladen (20)

5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
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...
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 

Polymorphism Forms Software Reuse

  • 1. Introduction Forms of Polymorphism Summary References POLYMORPHISM AND SOFTWARE REUSE Muhammad Adil Raja Roaming Researchers, Inc. cbna April 20, 2015
  • 2. Introduction Forms of Polymorphism Summary References OUTLINE I INTRODUCTION FORMS OF POLYMORPHISM SUMMARY REFERENCES
  • 3. Introduction Forms of Polymorphism Summary References INTRODUCTION • In this chapter and the four that follow we will start to investigate polymorphism, as it is found in many forms in object-oriented languages. • In this chapter we will outline the four major types of polymorphism, then explore them in more detail in the later chapters. • The different mechanisms each have the same goal of encouraging software reuse, facilitating ease of understanding and speeding application development.
  • 4. Introduction Forms of Polymorphism Summary References DEFINITION OF POLYMORPHISM MESSAGE SYNTAX • Polymorphous: Having, or assuming, various forms, characters, or styles. • From greek routes, poly = many, and Morphos = form (Morphus was the greek god of sleep, who could assume many forms, and from which we derive the name Morphine, among other things). • A polymorphic compound can crystalize in many forms, such as carbon, which can be graphite, diamonds, or fullerenes. • In programming languages, used for a variety of different mechanisms. • Usage of the term is confused by the fact that it means something slightly different in the functional programming community than it does in the OO world.)
  • 5. Introduction Forms of Polymorphism Summary References FORMS OF POLYMORPHISM IN OOP • There are four major forms of polymorphism in object-oriented languages: • Overloading (ad hoc polymorphism) – one name that refers to two or more different implementations. • Overriding (inclusion polymorphism) – A child class redefining a method inherited from a parent class. • The Polymorphic Variable (assignment polymorphism) – A variable that can hold different types of values during the course of execution. • It is called Pure Polymorphism when a polymorphic variable is used as a parameter. • Generics (or Templates) – A way of creating general tools or classes by parameterizing on types.
  • 6. Introduction Forms of Polymorphism Summary References TWO FORMS OF SOFTWARE REUSE • One of the major goals of OOP is software reuse. • We can illustrate this by considering two different approaches to reuse: • Inheritance – the is-a relationship. • Composition – the has-a relationship. • We do this by considering an example problem that could use either mechanism.
  • 7. Introduction Forms of Polymorphism Summary References EXAMPLE – BUILDING SETS FROM LISTS • Suppose we have already a List data type with the following behavior: • Want to build the Set data type (elements are unique). LISTS class L i s t { public : void add ( int ) ; int includes ( int ) ; void remove ( int ) ; int firstElement ( ) ; } ;
  • 8. Introduction Forms of Polymorphism Summary References USING INHERITANCE Only need specify what is new - the addition method. Everything else is given for free. INHERITANCE class Set : public L i s t { public : void add ( int ) ; } ; void Set : : add ( int x ) { i f ( ! includes ( x ) ) / / only include i f not already there L i s t : : add ( x ) ; }
  • 9. Introduction Forms of Polymorphism Summary References USING COMPOSITION • Everything must be redefined, but implementation can make use of the list data structure. COMPOSITION class Set { public : void add ( int ) ; int includes ( int ) ; void remove ( int ) ; int firstElement ( ) ; private : L i s t data ; } ; void Set : : add ( int x ) { i f ( ! data . includes ( x ) ) data . add ( x ) ; } int Set : : includes ( int x ) { return data . includes ( x ) ; } void Set : : remove ( int x ) { data . remove ( x ) ; } int Set : : firstElement ( ) { return data . firstElement ( ) ; }
  • 10. Introduction Forms of Polymorphism Summary References ADVANTAGES AND DISADVANTAGES OF EACH MECHANISM • Composition is simpler, and clearly indicates what operations are provided. • Inheritance makes for shorter code, possibly increased functionality, but makes it more difficult to understand what behavior is being provided. • Inheritance may open to the door for unintended usage, by means of unintended inheritance of behavior. • Easier to change underlying details using composition (i.e., change the data representation). • Inheritance may permit polymorphism. • Understandability is a toss-up, each has different complexity issues (size versus inheritance tree depth). • Very small execution time advantage for inheritance.
  • 11. Introduction Forms of Polymorphism 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, beaver.