SlideShare a Scribd company logo
Implications of
Substitution
Muhammad Adil
Raja
Introduction
The is-a
Relationship
Summary
References
IMPLICATIONS OF SUBSTITUTION
Muhammad Adil Raja
Roaming Researchers, Inc.
cbna
April 19, 2015
Implications of
Substitution
Muhammad Adil
Raja
Introduction
The is-a
Relationship
Summary
References
OUTLINE I
INTRODUCTION
THE IS-A RELATIONSHIP
SUMMARY
REFERENCES
Implications of
Substitution
Muhammad Adil
Raja
Introduction
The is-a
Relationship
Summary
References
INTRODUCTION
We will investigate some of the implications of the
principle of substitution in statically typed
object-oriented programming languages.
In particular, we will consider:
The impact on memory management
The meaning of assignment
The distinction between testing for identity and
testing for equality
Implications of
Substitution
Muhammad Adil
Raja
Introduction
The is-a
Relationship
Summary
References
THE IDEALIZATION OF IS-A RELATIONSHIP
MESSAGE SYNTAX
A TextWindow is-a Window.
Because TextWindow is subclassed from Window, all
behavior associated with Windows is also manifest
by instances of TextWindow.
Therefore, a variable declared as maintaining an
instance of Window should be able to hold a value of
type TextWindow.
Unfortunately, practical programming language
implementation issues complicate this idealized
picture.
Implications of
Substitution
Muhammad Adil
Raja
Introduction
The is-a
Relationship
Summary
References
MEMORY ALLOCATION – STACK AND HEAP
BASED
Generally, programming languages use two different
techniques for allocation of memory.
Stack-based allocation.
Amount of space required is determined at compile
time, based on static types of variables.
Memory allocation and release is tied to procedure
entry/exit.
Can be performed very efficiently.
Heap-based allocation.
Amount of space used can be determined at
run-time, based upon dynamic considerations.
Memory allocation and release is not tied to
procedure entry/exit, and either must be handled by
user or by a run-time library (garbage collection).
Generally considered to be somewhat less efficient.
Implications of
Substitution
Muhammad Adil
Raja
Introduction
The is-a
Relationship
Summary
References
THE PROBLEM WITH SUBSTITUTION
SUBSTITUTION
class Window {
public : Window x ; / / how much space to set aside?
virtual void oops ( ) ; TextWindow y ;
private : x = y ; / / what should happen here?
int height ;
int width ;
} ;
class TextWindow : public Window {
public :
virtual void oops ( ) ;
private :
char ∗ contents ;
int cursorLocation ;
} ;
Implications of
Substitution
Muhammad Adil
Raja
Introduction
The is-a
Relationship
Summary
References
HOW MUCH MEMORY TO SET ASIDE
How much memory should be set aside for the variable x
?
1. (Minimum Static Space Allocation) Allocate the
amount of space necessary for the base class only.
(C++)
2. (Maximum Static Space Allocation) Allocate the
amount of space for the largest subclass.
3. (Dynamic Space Allocation) Allocate for x only the
amount of space required to hold a pointer.
(Smalltalk, Java)
Implications of
Substitution
Muhammad Adil
Raja
Introduction
The is-a
Relationship
Summary
References
MINIMUM STATIC SPACE ALLOCATION
The language C++ uses the minimum static space
allocation approach.
This is very efficient, but leads to some subtle
difficulties.
What happens in the following assignment?
ASSIGNMENT
Window x ;
TextWindow y ;
x = y ;
Implications of
Substitution
Muhammad Adil
Raja
Introduction
The is-a
Relationship
Summary
References
ASSIGNING A LARGER VALUE TO A SMALLER
BOX
FIGURE : Assignment
Implications of
Substitution
Muhammad Adil
Raja
Introduction
The is-a
Relationship
Summary
References
THE SLICING PROBLEM
The problem is you are trying to take a large box and
squeeze it into a small space. Clearly this won’t
work. Thus, the extra fields are simply sliced off.
Question: Does this matter?
Answer: Only if somebody notices.
Solution: Design a language to make it difficult to
notice.
Implications of
Substitution
Muhammad Adil
Raja
Introduction
The is-a
Relationship
Summary
References
RULES FOR MEMBER FUNCTION BINDING IN
C++
The rules for deciding what member function to execute
are complicated because of the slicing problem.
1. With variables that are declared normally, the binding
of member function name to function body is based
on the static type of the argument (regardless
whether the function is declared virtual or not).
2. With variables that are declared as references or
pointers, the binding of the member function name to
function body is based on the dynamic type if the
function is declared as virtual, and the static type if
not.
Implications of
Substitution
Muhammad Adil
Raja
Introduction
The is-a
Relationship
Summary
References
ILLUSTRATION
ILLUSTRATION
void Window : : oops ( )
{ p r i n t f ( "Window oops  n" ) ; }
void TextWindow : : oops ( )
{ p r i n t f ( " TextWindow oops %d  n" , cursorLocation ) ;
TextWindow x ;
Window a ;
Window ∗ b ;
TextWindow ∗ c ;
a = x ; a . oops ( ) ; / / executes Window version
b = &x ; b−>oops ( ) ; / / executes TextWindow or Window version ;
c = &x ; c−>oops ( ) ; / / executes TextWindow version
Implications of
Substitution
Muhammad Adil
Raja
Introduction
The is-a
Relationship
Summary
References
MINIMUM STATIC SPACE ALLOCATION
A different approach would be to allocate the
Maximum amount of space you would ever need.
Would nicely solve the slicing problem.
Would often allocate unused space.
Maximum amount of space not known until all
classes have been seen.
For this reason, not used in practice.
Implications of
Substitution
Muhammad Adil
Raja
Introduction
The is-a
Relationship
Summary
References
DYNAMIC MEMORY ALLOCATION
In the third approach, all objects are actually
pointers.
Only enough space for a pointer is allocated at
compile time.
Actual data storage is allocated on the heap at
run-time.
Used in Smalltalk, Object Pascal, and Objective-C,
Java.
Requires user to explicitly allocate new objects and,
in some languages, explicitly free no longer used
storage.
May also lead to pointer semantics for assignment
and equality testing.
Implications of
Substitution
Muhammad Adil
Raja
Introduction
The is-a
Relationship
Summary
References
MEANING OF ASSIGNMENT
What does it mean when an instance of a class is
assigned to another variable?
ASSIGNMENT
class Box {
public int value ;
}
Box x = new Box ( ) ;
x . value = 7;
Box y = x ;
y . value = 12; / / what i s x . value?
Two possibilities:
Copy semantics. x and y are independent of each
other, a change in one has no effect on the other.
Pointer semantcs. x and y refer to the same object,
and hence a change in one will alter the other.
Implications of
Substitution
Muhammad Adil
Raja
Introduction
The is-a
Relationship
Summary
References
COPY SEMANTICS VS POINTER SEMANTICS
If a value is indirectly accessed through a pointer,
when an assignment is performed (or equality test is
made) is the quantity assigned simply the pointer or
is it the actual value?
Implications of
Substitution
Muhammad Adil
Raja
Introduction
The is-a
Relationship
Summary
References
PROBLEMS WITH POINTER SEMANTICS
If x is assigned to y and then changes are made to x,
are these changes reflected in y?
If x is explicitly freed, what happens if the user tries
to access memory through y?
In C++, programmer can make assignment (equality
testing) mean anything they want.
Object Pascal, Java uses pointer semantics, no
built-in provision for copies.
Smalltalk and Objective-C use pointer semantics,
have several techniques for making copies.
Implications of
Substitution
Muhammad Adil
Raja
Introduction
The is-a
Relationship
Summary
References
AN OLD JOKE CONCERNING EQUALITY
There is an old joke that goes something like this: A
man walks into a pizza parlor and sits down.
A waiter comes to the table and asks the man what
he would like to order. The man looks around the
room, then points to the woman sitting at the next
table, and says “I’ll have what she is eating”.
The waiter thereupon walks to the womans table,
picks up the half-eaten pizza from in front of her, and
places it before the startled customer.
A classic confusion between equality and identity.
Implications of
Substitution
Muhammad Adil
Raja
Introduction
The is-a
Relationship
Summary
References
EQUALITY AND IDENTITY
A test for identity asks whether two variables refer to
exactly the same object.
A test for equality asks whether two variables refer to
values that are equivalent.
Of course, the meaning of equivalent is inheritently
domain specific.
Object-oriented languages allow the programmer to
control the meaning of the equality test by allowing
the redefinition of a standard method. (for example,
equals in Java).
Implications of
Substitution
Muhammad Adil
Raja
Introduction
The is-a
Relationship
Summary
References
PARADOXES OF EQUALITY I
But child classes cannot change the type signature
of overridden methods.
This means the argument must often be more
general than one would like:
EQUALITY
class Object {
public boolean equals ( Object r i g h t ) {
. . .
}
}
class PlayingCard extends Object {
public boolean equals ( Object r i g h t ) {
. . . / / r i g h t must be object even i f we are only
. . . / / interested in comparing cards to cards
}
}
And if you add inheritance into the mix, the possibilities
for paradoxical behavior increase even more.
Implications of
Substitution
Muhammad Adil
Raja
Introduction
The is-a
Relationship
Summary
References
PARADOXES OF EQUALITY II
EQUALITY
class Foo {
boolean equals ( Object r i g h t ) { . . . }
}
Foo a , b ;
i f ( a . equals ( b ) ) / / even i f t h i s i s true
i f ( b . equals ( a ) ) / / no guarantee that t h i s i s true
Implications of
Substitution
Muhammad Adil
Raja
Introduction
The is-a
Relationship
Summary
References
PARADOXES OF EQUALITY III
And if you add inheritance into the mix, the possibilities
for paradoxical behavior increase even more.
EQUALITY
class Parent {
boolean equals ( Object x ) { . . . }
}
class Child extends Parent {
boolean equals ( Object x ) { . . . }
}
Parent p ;
Child c ;
i f ( p . equals ( c ) ) / / w i l l execute using the parent method
i f ( c . equals ( p ) ) / / w i l l execute using the childs method
Implications of
Substitution
Muhammad Adil
Raja
Introduction
The is-a
Relationship
Summary
References
SUMMARY I
We have explored the implications that result from
the inclusion of the principle of substitution in an
object oriented programming language.
Because values are not known until run time, you
either have complex semantics (as in C++) or objects
are dynamic (as in Java and most other languages).
Because objects are dynamic, most object-oriented
languages end up using a garbage collection system.
Dynamic semantics naturally lean to pointer
semantics for assignment
Pointer semantics mean that equality and identity are
two different concepts
Since equality is domain specific, the programmer
must be free to redefine the meaning as appropriate.
Implications of
Substitution
Muhammad Adil
Raja
Introduction
The is-a
Relationship
Summary
References
SUMMARY II
Because the programmer can redefine equality
arbitrarily, there is no guarantee that semantics of
equals is preserved.
Implications of
Substitution
Muhammad Adil
Raja
Introduction
The is-a
Relationship
Summary
References
REFERENCES I
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:
CambridgeUS, dove.

More Related Content

What's hot

art.pdf
art.pdfart.pdf
art.pdf
ferejadawud
 
SOLID principles
SOLID principlesSOLID principles
SOLID principles
Dmitry Kandalov
 
Solid Principles
Solid PrinciplesSolid Principles
Solid PrinciplesHitheshh
 
Abstraction in c++ and Real Life Example of Abstraction in C++
Abstraction in c++ and Real Life Example of Abstraction in C++Abstraction in c++ and Real Life Example of Abstraction in C++
Abstraction in c++ and Real Life Example of Abstraction in C++
Hitesh Kumar
 
Sofwear deasign and need of design pattern
Sofwear deasign and need of design patternSofwear deasign and need of design pattern
Sofwear deasign and need of design patternchetankane
 
Abstraction and Encapsulation
Abstraction and EncapsulationAbstraction and Encapsulation
Abstraction and Encapsulation
Haris Bin Zahid
 
Java OOPS Concept
Java OOPS ConceptJava OOPS Concept
Java OOPS Concept
Richa Gupta
 
Programming Paradigms
Programming ParadigmsProgramming Paradigms
Programming Paradigms
Directi Group
 
Abstract class
Abstract classAbstract class
Abstract class
Hoang Nguyen
 
SlidesSeams15
SlidesSeams15SlidesSeams15
SlidesSeams15
Luca Sabatucci
 
C# Interface | Interfaces In C# | C# Interfaces Explained | C# Tutorial For B...
C# Interface | Interfaces In C# | C# Interfaces Explained | C# Tutorial For B...C# Interface | Interfaces In C# | C# Interfaces Explained | C# Tutorial For B...
C# Interface | Interfaces In C# | C# Interfaces Explained | C# Tutorial For B...
Simplilearn
 
DOLCE and Pi-Calculus Rendezvous Semantics for Business Processes
DOLCE and Pi-Calculus Rendezvous Semantics for Business ProcessesDOLCE and Pi-Calculus Rendezvous Semantics for Business Processes
DOLCE and Pi-Calculus Rendezvous Semantics for Business Processes
Violeta Damjanovic-Behrendt
 
Virtual function
Virtual functionVirtual function
Virtual function
sdrhr
 
Lecture 18
Lecture 18Lecture 18
Lecture 18
talha ijaz
 
Abstract Class Presentation
Abstract Class PresentationAbstract Class Presentation
Abstract Class Presentation
tigerwarn
 
Unified Programming Theory
Unified Programming TheoryUnified Programming Theory
Unified Programming Theory
Crazy Mathematician
 
Highly Strung
Highly StrungHighly Strung
Highly Strung
Kevlin Henney
 
Behavioral Design Patterns
Behavioral Design PatternsBehavioral Design Patterns
Behavioral Design Patterns
Lidan Hifi
 
Bert pre_training_of_deep_bidirectional_transformers_for_language_understanding
Bert  pre_training_of_deep_bidirectional_transformers_for_language_understandingBert  pre_training_of_deep_bidirectional_transformers_for_language_understanding
Bert pre_training_of_deep_bidirectional_transformers_for_language_understanding
ThyrixYang1
 

What's hot (20)

art.pdf
art.pdfart.pdf
art.pdf
 
SOLID principles
SOLID principlesSOLID principles
SOLID principles
 
Solid Principles
Solid PrinciplesSolid Principles
Solid Principles
 
Abstraction in c++ and Real Life Example of Abstraction in C++
Abstraction in c++ and Real Life Example of Abstraction in C++Abstraction in c++ and Real Life Example of Abstraction in C++
Abstraction in c++ and Real Life Example of Abstraction in C++
 
javainterface
javainterfacejavainterface
javainterface
 
Sofwear deasign and need of design pattern
Sofwear deasign and need of design patternSofwear deasign and need of design pattern
Sofwear deasign and need of design pattern
 
Abstraction and Encapsulation
Abstraction and EncapsulationAbstraction and Encapsulation
Abstraction and Encapsulation
 
Java OOPS Concept
Java OOPS ConceptJava OOPS Concept
Java OOPS Concept
 
Programming Paradigms
Programming ParadigmsProgramming Paradigms
Programming Paradigms
 
Abstract class
Abstract classAbstract class
Abstract class
 
SlidesSeams15
SlidesSeams15SlidesSeams15
SlidesSeams15
 
C# Interface | Interfaces In C# | C# Interfaces Explained | C# Tutorial For B...
C# Interface | Interfaces In C# | C# Interfaces Explained | C# Tutorial For B...C# Interface | Interfaces In C# | C# Interfaces Explained | C# Tutorial For B...
C# Interface | Interfaces In C# | C# Interfaces Explained | C# Tutorial For B...
 
DOLCE and Pi-Calculus Rendezvous Semantics for Business Processes
DOLCE and Pi-Calculus Rendezvous Semantics for Business ProcessesDOLCE and Pi-Calculus Rendezvous Semantics for Business Processes
DOLCE and Pi-Calculus Rendezvous Semantics for Business Processes
 
Virtual function
Virtual functionVirtual function
Virtual function
 
Lecture 18
Lecture 18Lecture 18
Lecture 18
 
Abstract Class Presentation
Abstract Class PresentationAbstract Class Presentation
Abstract Class Presentation
 
Unified Programming Theory
Unified Programming TheoryUnified Programming Theory
Unified Programming Theory
 
Highly Strung
Highly StrungHighly Strung
Highly Strung
 
Behavioral Design Patterns
Behavioral Design PatternsBehavioral Design Patterns
Behavioral Design Patterns
 
Bert pre_training_of_deep_bidirectional_transformers_for_language_understanding
Bert  pre_training_of_deep_bidirectional_transformers_for_language_understandingBert  pre_training_of_deep_bidirectional_transformers_for_language_understanding
Bert pre_training_of_deep_bidirectional_transformers_for_language_understanding
 

Similar to Implications of Substitution

Advance oops concepts
Advance oops conceptsAdvance oops concepts
Advance oops concepts
Sangharsh agarwal
 
Object Interconnections
Object InterconnectionsObject Interconnections
Object Interconnections
adil raja
 
Structural pattern 3
Structural pattern 3Structural pattern 3
Structural pattern 3
Naga Muruga
 
Lecture 5 interface.pdf
Lecture  5 interface.pdfLecture  5 interface.pdf
Lecture 5 interface.pdf
AdilAijaz3
 
Generics
GenericsGenerics
Generics
adil raja
 
Interface in java By Dheeraj Kumar Singh
Interface in java By Dheeraj Kumar SinghInterface in java By Dheeraj Kumar Singh
Interface in java By Dheeraj Kumar Singh
dheeraj_cse
 
[ppt] A Comparison of SAWSDL Based Semantic Web Service Discovery Algorithms
[ppt] A Comparison of SAWSDL Based Semantic Web Service Discovery Algorithms[ppt] A Comparison of SAWSDL Based Semantic Web Service Discovery Algorithms
[ppt] A Comparison of SAWSDL Based Semantic Web Service Discovery Algorithms
Shiva Sandeep Garlapati
 
Graph-to-Graph Transformer for Transition-based Dependency Parsing
Graph-to-Graph Transformer for Transition-based Dependency ParsingGraph-to-Graph Transformer for Transition-based Dependency Parsing
Graph-to-Graph Transformer for Transition-based Dependency Parsing
Alireza Mohammadshahi
 
Asp.net main
Asp.net mainAsp.net main
Asp.net main
YogeshDhamke2
 
Javascript
JavascriptJavascript
Javascript
Sheldon Abraham
 
Subclasses and Subtypes
Subclasses and SubtypesSubclasses and Subtypes
Subclasses and Subtypes
adil raja
 
10.1.1.70.8789
10.1.1.70.878910.1.1.70.8789
10.1.1.70.8789
Hoài Bùi
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
Ashita Agrawal
 
On Applying Or-Parallelism and Tabling to Logic Programs
On Applying Or-Parallelism and Tabling to Logic ProgramsOn Applying Or-Parallelism and Tabling to Logic Programs
On Applying Or-Parallelism and Tabling to Logic Programs
Lino Possamai
 
[Emnlp] what is glo ve part ii - towards data science
[Emnlp] what is glo ve  part ii - towards data science[Emnlp] what is glo ve  part ii - towards data science
[Emnlp] what is glo ve part ii - towards data science
Nikhil Jaiswal
 
Seminar
SeminarSeminar
PATTERNS04 - Structural Design Patterns
PATTERNS04 - Structural Design PatternsPATTERNS04 - Structural Design Patterns
PATTERNS04 - Structural Design Patterns
Michael Heron
 
Intro to Functional Programming @ Scala Montreal
Intro to Functional Programming @ Scala MontrealIntro to Functional Programming @ Scala Montreal
Intro to Functional Programming @ Scala Montreal
felixtrepanier
 
Java oops and fundamentals
Java oops and fundamentalsJava oops and fundamentals
Java oops and fundamentals
javaease
 

Similar to Implications of Substitution (20)

Advance oops concepts
Advance oops conceptsAdvance oops concepts
Advance oops concepts
 
Object Interconnections
Object InterconnectionsObject Interconnections
Object Interconnections
 
Structural pattern 3
Structural pattern 3Structural pattern 3
Structural pattern 3
 
Lecture 5 interface.pdf
Lecture  5 interface.pdfLecture  5 interface.pdf
Lecture 5 interface.pdf
 
Generics
GenericsGenerics
Generics
 
Interface in java By Dheeraj Kumar Singh
Interface in java By Dheeraj Kumar SinghInterface in java By Dheeraj Kumar Singh
Interface in java By Dheeraj Kumar Singh
 
[ppt] A Comparison of SAWSDL Based Semantic Web Service Discovery Algorithms
[ppt] A Comparison of SAWSDL Based Semantic Web Service Discovery Algorithms[ppt] A Comparison of SAWSDL Based Semantic Web Service Discovery Algorithms
[ppt] A Comparison of SAWSDL Based Semantic Web Service Discovery Algorithms
 
Graph-to-Graph Transformer for Transition-based Dependency Parsing
Graph-to-Graph Transformer for Transition-based Dependency ParsingGraph-to-Graph Transformer for Transition-based Dependency Parsing
Graph-to-Graph Transformer for Transition-based Dependency Parsing
 
General oops concepts
General oops conceptsGeneral oops concepts
General oops concepts
 
Asp.net main
Asp.net mainAsp.net main
Asp.net main
 
Javascript
JavascriptJavascript
Javascript
 
Subclasses and Subtypes
Subclasses and SubtypesSubclasses and Subtypes
Subclasses and Subtypes
 
10.1.1.70.8789
10.1.1.70.878910.1.1.70.8789
10.1.1.70.8789
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
 
On Applying Or-Parallelism and Tabling to Logic Programs
On Applying Or-Parallelism and Tabling to Logic ProgramsOn Applying Or-Parallelism and Tabling to Logic Programs
On Applying Or-Parallelism and Tabling to Logic Programs
 
[Emnlp] what is glo ve part ii - towards data science
[Emnlp] what is glo ve  part ii - towards data science[Emnlp] what is glo ve  part ii - towards data science
[Emnlp] what is glo ve part ii - towards data science
 
Seminar
SeminarSeminar
Seminar
 
PATTERNS04 - Structural Design Patterns
PATTERNS04 - Structural Design PatternsPATTERNS04 - Structural Design Patterns
PATTERNS04 - Structural Design Patterns
 
Intro to Functional Programming @ Scala Montreal
Intro to Functional Programming @ Scala MontrealIntro to Functional Programming @ Scala Montreal
Intro to Functional Programming @ Scala Montreal
 
Java oops and fundamentals
Java oops and fundamentalsJava oops and fundamentals
Java oops and fundamentals
 

More from adil raja

ANNs.pdf
ANNs.pdfANNs.pdf
ANNs.pdf
adil raja
 
A Software Requirements Specification
A Software Requirements SpecificationA Software Requirements Specification
A Software Requirements Specification
adil 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 Vehicles
adil raja
 
DevOps Demystified
DevOps DemystifiedDevOps Demystified
DevOps Demystified
adil 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 Research
adil raja
 
The Knock Knock Protocol
The Knock Knock ProtocolThe Knock Knock Protocol
The Knock Knock Protocol
adil raja
 
File Transfer Through Sockets
File Transfer Through SocketsFile Transfer Through Sockets
File Transfer Through Sockets
adil raja
 
Remote Command Execution
Remote Command ExecutionRemote Command Execution
Remote Command Execution
adil 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 Pakistan
adil raja
 
Data Warehousing
Data WarehousingData Warehousing
Data Warehousing
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
 
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 VoIP
adil raja
 
VoIP
VoIPVoIP
VoIP
adil raja
 
ULMAN GUI Specifications
ULMAN GUI SpecificationsULMAN GUI Specifications
ULMAN GUI Specifications
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
 
ULMAN-GUI
ULMAN-GUIULMAN-GUI
ULMAN-GUI
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
 

More from 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...
 

Recently uploaded

Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
Ortus Solutions, Corp
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
RISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent EnterpriseRISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent Enterprise
Srikant77
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
informapgpstrackings
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
vrstrong314
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 

Recently uploaded (20)

Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
RISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent EnterpriseRISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent Enterprise
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 

Implications of Substitution

  • 1. Implications of Substitution Muhammad Adil Raja Introduction The is-a Relationship Summary References IMPLICATIONS OF SUBSTITUTION Muhammad Adil Raja Roaming Researchers, Inc. cbna April 19, 2015
  • 2. Implications of Substitution Muhammad Adil Raja Introduction The is-a Relationship Summary References OUTLINE I INTRODUCTION THE IS-A RELATIONSHIP SUMMARY REFERENCES
  • 3. Implications of Substitution Muhammad Adil Raja Introduction The is-a Relationship Summary References INTRODUCTION We will investigate some of the implications of the principle of substitution in statically typed object-oriented programming languages. In particular, we will consider: The impact on memory management The meaning of assignment The distinction between testing for identity and testing for equality
  • 4. Implications of Substitution Muhammad Adil Raja Introduction The is-a Relationship Summary References THE IDEALIZATION OF IS-A RELATIONSHIP MESSAGE SYNTAX A TextWindow is-a Window. Because TextWindow is subclassed from Window, all behavior associated with Windows is also manifest by instances of TextWindow. Therefore, a variable declared as maintaining an instance of Window should be able to hold a value of type TextWindow. Unfortunately, practical programming language implementation issues complicate this idealized picture.
  • 5. Implications of Substitution Muhammad Adil Raja Introduction The is-a Relationship Summary References MEMORY ALLOCATION – STACK AND HEAP BASED Generally, programming languages use two different techniques for allocation of memory. Stack-based allocation. Amount of space required is determined at compile time, based on static types of variables. Memory allocation and release is tied to procedure entry/exit. Can be performed very efficiently. Heap-based allocation. Amount of space used can be determined at run-time, based upon dynamic considerations. Memory allocation and release is not tied to procedure entry/exit, and either must be handled by user or by a run-time library (garbage collection). Generally considered to be somewhat less efficient.
  • 6. Implications of Substitution Muhammad Adil Raja Introduction The is-a Relationship Summary References THE PROBLEM WITH SUBSTITUTION SUBSTITUTION class Window { public : Window x ; / / how much space to set aside? virtual void oops ( ) ; TextWindow y ; private : x = y ; / / what should happen here? int height ; int width ; } ; class TextWindow : public Window { public : virtual void oops ( ) ; private : char ∗ contents ; int cursorLocation ; } ;
  • 7. Implications of Substitution Muhammad Adil Raja Introduction The is-a Relationship Summary References HOW MUCH MEMORY TO SET ASIDE How much memory should be set aside for the variable x ? 1. (Minimum Static Space Allocation) Allocate the amount of space necessary for the base class only. (C++) 2. (Maximum Static Space Allocation) Allocate the amount of space for the largest subclass. 3. (Dynamic Space Allocation) Allocate for x only the amount of space required to hold a pointer. (Smalltalk, Java)
  • 8. Implications of Substitution Muhammad Adil Raja Introduction The is-a Relationship Summary References MINIMUM STATIC SPACE ALLOCATION The language C++ uses the minimum static space allocation approach. This is very efficient, but leads to some subtle difficulties. What happens in the following assignment? ASSIGNMENT Window x ; TextWindow y ; x = y ;
  • 9. Implications of Substitution Muhammad Adil Raja Introduction The is-a Relationship Summary References ASSIGNING A LARGER VALUE TO A SMALLER BOX FIGURE : Assignment
  • 10. Implications of Substitution Muhammad Adil Raja Introduction The is-a Relationship Summary References THE SLICING PROBLEM The problem is you are trying to take a large box and squeeze it into a small space. Clearly this won’t work. Thus, the extra fields are simply sliced off. Question: Does this matter? Answer: Only if somebody notices. Solution: Design a language to make it difficult to notice.
  • 11. Implications of Substitution Muhammad Adil Raja Introduction The is-a Relationship Summary References RULES FOR MEMBER FUNCTION BINDING IN C++ The rules for deciding what member function to execute are complicated because of the slicing problem. 1. With variables that are declared normally, the binding of member function name to function body is based on the static type of the argument (regardless whether the function is declared virtual or not). 2. With variables that are declared as references or pointers, the binding of the member function name to function body is based on the dynamic type if the function is declared as virtual, and the static type if not.
  • 12. Implications of Substitution Muhammad Adil Raja Introduction The is-a Relationship Summary References ILLUSTRATION ILLUSTRATION void Window : : oops ( ) { p r i n t f ( "Window oops n" ) ; } void TextWindow : : oops ( ) { p r i n t f ( " TextWindow oops %d n" , cursorLocation ) ; TextWindow x ; Window a ; Window ∗ b ; TextWindow ∗ c ; a = x ; a . oops ( ) ; / / executes Window version b = &x ; b−>oops ( ) ; / / executes TextWindow or Window version ; c = &x ; c−>oops ( ) ; / / executes TextWindow version
  • 13. Implications of Substitution Muhammad Adil Raja Introduction The is-a Relationship Summary References MINIMUM STATIC SPACE ALLOCATION A different approach would be to allocate the Maximum amount of space you would ever need. Would nicely solve the slicing problem. Would often allocate unused space. Maximum amount of space not known until all classes have been seen. For this reason, not used in practice.
  • 14. Implications of Substitution Muhammad Adil Raja Introduction The is-a Relationship Summary References DYNAMIC MEMORY ALLOCATION In the third approach, all objects are actually pointers. Only enough space for a pointer is allocated at compile time. Actual data storage is allocated on the heap at run-time. Used in Smalltalk, Object Pascal, and Objective-C, Java. Requires user to explicitly allocate new objects and, in some languages, explicitly free no longer used storage. May also lead to pointer semantics for assignment and equality testing.
  • 15. Implications of Substitution Muhammad Adil Raja Introduction The is-a Relationship Summary References MEANING OF ASSIGNMENT What does it mean when an instance of a class is assigned to another variable? ASSIGNMENT class Box { public int value ; } Box x = new Box ( ) ; x . value = 7; Box y = x ; y . value = 12; / / what i s x . value? Two possibilities: Copy semantics. x and y are independent of each other, a change in one has no effect on the other. Pointer semantcs. x and y refer to the same object, and hence a change in one will alter the other.
  • 16. Implications of Substitution Muhammad Adil Raja Introduction The is-a Relationship Summary References COPY SEMANTICS VS POINTER SEMANTICS If a value is indirectly accessed through a pointer, when an assignment is performed (or equality test is made) is the quantity assigned simply the pointer or is it the actual value?
  • 17. Implications of Substitution Muhammad Adil Raja Introduction The is-a Relationship Summary References PROBLEMS WITH POINTER SEMANTICS If x is assigned to y and then changes are made to x, are these changes reflected in y? If x is explicitly freed, what happens if the user tries to access memory through y? In C++, programmer can make assignment (equality testing) mean anything they want. Object Pascal, Java uses pointer semantics, no built-in provision for copies. Smalltalk and Objective-C use pointer semantics, have several techniques for making copies.
  • 18. Implications of Substitution Muhammad Adil Raja Introduction The is-a Relationship Summary References AN OLD JOKE CONCERNING EQUALITY There is an old joke that goes something like this: A man walks into a pizza parlor and sits down. A waiter comes to the table and asks the man what he would like to order. The man looks around the room, then points to the woman sitting at the next table, and says “I’ll have what she is eating”. The waiter thereupon walks to the womans table, picks up the half-eaten pizza from in front of her, and places it before the startled customer. A classic confusion between equality and identity.
  • 19. Implications of Substitution Muhammad Adil Raja Introduction The is-a Relationship Summary References EQUALITY AND IDENTITY A test for identity asks whether two variables refer to exactly the same object. A test for equality asks whether two variables refer to values that are equivalent. Of course, the meaning of equivalent is inheritently domain specific. Object-oriented languages allow the programmer to control the meaning of the equality test by allowing the redefinition of a standard method. (for example, equals in Java).
  • 20. Implications of Substitution Muhammad Adil Raja Introduction The is-a Relationship Summary References PARADOXES OF EQUALITY I But child classes cannot change the type signature of overridden methods. This means the argument must often be more general than one would like: EQUALITY class Object { public boolean equals ( Object r i g h t ) { . . . } } class PlayingCard extends Object { public boolean equals ( Object r i g h t ) { . . . / / r i g h t must be object even i f we are only . . . / / interested in comparing cards to cards } } And if you add inheritance into the mix, the possibilities for paradoxical behavior increase even more.
  • 21. Implications of Substitution Muhammad Adil Raja Introduction The is-a Relationship Summary References PARADOXES OF EQUALITY II EQUALITY class Foo { boolean equals ( Object r i g h t ) { . . . } } Foo a , b ; i f ( a . equals ( b ) ) / / even i f t h i s i s true i f ( b . equals ( a ) ) / / no guarantee that t h i s i s true
  • 22. Implications of Substitution Muhammad Adil Raja Introduction The is-a Relationship Summary References PARADOXES OF EQUALITY III And if you add inheritance into the mix, the possibilities for paradoxical behavior increase even more. EQUALITY class Parent { boolean equals ( Object x ) { . . . } } class Child extends Parent { boolean equals ( Object x ) { . . . } } Parent p ; Child c ; i f ( p . equals ( c ) ) / / w i l l execute using the parent method i f ( c . equals ( p ) ) / / w i l l execute using the childs method
  • 23. Implications of Substitution Muhammad Adil Raja Introduction The is-a Relationship Summary References SUMMARY I We have explored the implications that result from the inclusion of the principle of substitution in an object oriented programming language. Because values are not known until run time, you either have complex semantics (as in C++) or objects are dynamic (as in Java and most other languages). Because objects are dynamic, most object-oriented languages end up using a garbage collection system. Dynamic semantics naturally lean to pointer semantics for assignment Pointer semantics mean that equality and identity are two different concepts Since equality is domain specific, the programmer must be free to redefine the meaning as appropriate.
  • 24. Implications of Substitution Muhammad Adil Raja Introduction The is-a Relationship Summary References SUMMARY II Because the programmer can redefine equality arbitrarily, there is no guarantee that semantics of equals is preserved.
  • 25. Implications of Substitution Muhammad Adil Raja Introduction The is-a Relationship Summary References REFERENCES I 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: CambridgeUS, dove.