SlideShare une entreprise Scribd logo
1  sur  5
ICS 313 - Fundamentals of Programming Languages 1
12. Object-Oriented Programming
12.1 Introduction
Categories of languages that support OOP:
1. OOP support is added to an existing language
C++ (also supports procedural and data-oriented programming)
Ada 95 (also supports procedural and data-oriented programming)
CLOS (also supports functional programming)
Scheme (also supports functional programming)
2. Support OOP, but have the same appearance and use the basic
structure of earlier imperative languages
Eiffel (not based directly on any previous language)
Java (based on C++)
3. Pure OOP languages
Smalltalk
ICS 313 - Fundamentals of Programming Languages 2
12.2 Object-Oriented Programming
Paradigm Evolution
1. Procedural - 1950s-1970s (procedural abstraction)
2. Data-Oriented - early 1980s (data abstraction)
3. OOP - late 1980s (Inheritance and dynamic binding)
Origins of Inheritance
Observations of the mid-late 1980s :
Productivity increases can come from reuse
Unfortunately, ADTs are difficult to reuse - never quite right
All ADTs are independent and at the same level
Inheritance solves both - reuse ADTs after minor
changes and define classes in a hierarchy
12.2 Object-Oriented Programming (continued)
OOP Definitions:
ADTs are called classes
Class instances are called objects
A class that inherits is a derived class or a subclass
The class from which another class inherits is a parent class or
superclass
Subprograms that define operations on objects are called
methods
The entire collection of methods of an object is called its
message protocol or message interface
Messages have two parts - a method name and the destination
object
In the simplest case, a class inherits all of the entities of its
parent
ICS 313 - Fundamentals of Programming Languages 3
12.2 Object-Oriented Programming (continued)
Inheritance can be complicated by access controls to encapsulated entities
A class can hide entities from its subclasses
A class can hide entities from its clients
A class can also hide entities for its clients while allowing its subclasses to see them
Besides inheriting methods as is, a class can modify an inherited method
The new one overrides the inherited one
The method in the parent is overriden
There are two kinds of variables in a class:
1. Class variables - one/class
2. Instance variables - one/object
There are two kinds of methods in a class:
1. Class methods – accept messages to the class
2. Instance methods – accept messages to objects
Single vs. Multiple Inheritance
One disadvantage of inheritance for reuse:
Creates interdependencies among classes that complicate maintenance
12.2 Object-Oriented Programming (continued)
Polymorphism in OOPLs
A polymorphic variable can be defined in a class that is able to
reference (or point to) objects of the class and objects of any of
its descendants
When a class hierarchy includes classes that override methods
and such methods are called through a polymorphic variable,
the binding to the correct method MUST be dynamic
This polymorphism simplifies the addition of new methods
A virtual method is one that does not include a definition (it only
defines a protocol)
A virtual class is one that includes at least one virtual method
A virtual class cannot be instantiated
ICS 313 - Fundamentals of Programming Languages 4
12.2 Object-Oriented Programming (continued)
Design Issues for OOPLs
1. The Exclusivity of Objects
a. Everything is an object
Advantage - elegance and purity
Disadvantage - slow operations on simple objects (e.g., float)
b. Add objects to a complete typing system
Advantage - fast operations on simple objects
Disadvantage - results in a confusing type system (two kinds of entities)
c. Include an imperative-style typing system for primitives but
make everything else objects
Advantage - fast operations on simple objects and a relatively small typing system
Disadvantage - still some confusion because of the two type systems
2. Are Subclasses Subtypes?
Does an is-a relationship hold between a parent class object
and an object of the subclass?
12.2 Object-Oriented Programming (continued)
3. Implementation and Interface Inheritance
If only the interface of the parent class is visible to the subclass,
it is interface inheritance
Disadvantage - can result in inefficiencies
If both the interface and the implementation of the parent class
is visible to the subclass, it is implementation inheritance
Disadvantage - changes to the parent class require recompilation of subclasses, and
sometimes even modification of subclasses
4. Type Checking and Polymorphism
Polymorphism may require dynamic type checking of
parameters and the return value
Dynamic type checking is costly and delays error detection
If overriding methods are restricted to having the same
parameter types and return type, the checking can be static
ICS 313 - Fundamentals of Programming Languages 5
12.2 Object-Oriented Programming (continued)
5. Single and Multiple Inheritance
Disadvantages of multiple inheritance:
Language and implementation complexity (in part due to name collisions)
Potential inefficiency - dynamic binding costs more with multiple inheritance (but not much)
Advantage:
Sometimes it is extremely convenient and valuable
6. Allocation and Deallocation of Objects
From where are objects allocated?
If they all live in the heap, references to them are uniform
Simplifies assignment - dereferencing can be implicit
Is deallocation explicit or implicit?
7. Dynamic and Static Binding
Should ALL binding of messages to methods be dynamic?
If none are, you lose the advantages of dynamic binding
If all are, it is inefficient

Contenu connexe

Tendances

Oo abap-sap-1206973306636228-5
Oo abap-sap-1206973306636228-5Oo abap-sap-1206973306636228-5
Oo abap-sap-1206973306636228-5
prakash185645
 

Tendances (20)

Oops abap fundamental
Oops abap fundamentalOops abap fundamental
Oops abap fundamental
 
Java interface
Java interface Java interface
Java interface
 
C#, OOP introduction and examples
C#, OOP introduction and examplesC#, OOP introduction and examples
C#, OOP introduction and examples
 
Object Orinted Programing(OOP) concepts \
Object Orinted Programing(OOP) concepts \Object Orinted Programing(OOP) concepts \
Object Orinted Programing(OOP) concepts \
 
Csci360 20
Csci360 20Csci360 20
Csci360 20
 
Csci360 20 (1)
Csci360 20 (1)Csci360 20 (1)
Csci360 20 (1)
 
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
 
EEE oops Vth semester viva questions with answer
EEE oops Vth semester viva questions with answerEEE oops Vth semester viva questions with answer
EEE oops Vth semester viva questions with answer
 
Core java questions
Core java questionsCore java questions
Core java questions
 
Abstract class in java
Abstract class in javaAbstract class in java
Abstract class in java
 
Unit 4 Java
Unit 4 JavaUnit 4 Java
Unit 4 Java
 
Ppt chapter06
Ppt chapter06Ppt chapter06
Ppt chapter06
 
Suga java training_with_footer
Suga java training_with_footerSuga java training_with_footer
Suga java training_with_footer
 
Object Oriented Programming - Basic Concepts
Object Oriented Programming - Basic ConceptsObject Oriented Programming - Basic Concepts
Object Oriented Programming - Basic Concepts
 
Lecture 18
Lecture 18Lecture 18
Lecture 18
 
Oo abap-sap-1206973306636228-5
Oo abap-sap-1206973306636228-5Oo abap-sap-1206973306636228-5
Oo abap-sap-1206973306636228-5
 
Mi0041 java and web design
Mi0041  java and web designMi0041  java and web design
Mi0041 java and web design
 
Polymorphism in java
Polymorphism in javaPolymorphism in java
Polymorphism in java
 
Inheritance
InheritanceInheritance
Inheritance
 
Automated Refactoring of Legacy Java Software to Default Methods Talk at GMU
Automated Refactoring of Legacy Java Software to Default Methods Talk at GMUAutomated Refactoring of Legacy Java Software to Default Methods Talk at GMU
Automated Refactoring of Legacy Java Software to Default Methods Talk at GMU
 

En vedette

Proporción nn Procesos Productivos
Proporción nn Procesos ProductivosProporción nn Procesos Productivos
Proporción nn Procesos Productivos
guestf83d576
 
01 c ce-–-andaime-fachadeiro-–-manual-de-montagem
01 c ce-–-andaime-fachadeiro-–-manual-de-montagem01 c ce-–-andaime-fachadeiro-–-manual-de-montagem
01 c ce-–-andaime-fachadeiro-–-manual-de-montagem
Janaina Xavier
 
Raji_new_July_2015
Raji_new_July_2015Raji_new_July_2015
Raji_new_July_2015
Raja Kumari
 

En vedette (14)

Presentación normas cacería
Presentación normas caceríaPresentación normas cacería
Presentación normas cacería
 
February wk 2
February wk 2February wk 2
February wk 2
 
Castravete ciupirea plantei
Castravete ciupirea planteiCastravete ciupirea plantei
Castravete ciupirea plantei
 
Proporción nn Procesos Productivos
Proporción nn Procesos ProductivosProporción nn Procesos Productivos
Proporción nn Procesos Productivos
 
1804.13
1804.131804.13
1804.13
 
sexe
sexesexe
sexe
 
Server Networking
Server NetworkingServer Networking
Server Networking
 
sexe
sexesexe
sexe
 
01 c ce-–-andaime-fachadeiro-–-manual-de-montagem
01 c ce-–-andaime-fachadeiro-–-manual-de-montagem01 c ce-–-andaime-fachadeiro-–-manual-de-montagem
01 c ce-–-andaime-fachadeiro-–-manual-de-montagem
 
Jf 17
Jf 17Jf 17
Jf 17
 
Masail Fiqhiyyah - Makalah Pandangan Hukum Islam Terhadap Aborsi
Masail Fiqhiyyah - Makalah Pandangan Hukum Islam Terhadap AborsiMasail Fiqhiyyah - Makalah Pandangan Hukum Islam Terhadap Aborsi
Masail Fiqhiyyah - Makalah Pandangan Hukum Islam Terhadap Aborsi
 
Raji_new_July_2015
Raji_new_July_2015Raji_new_July_2015
Raji_new_July_2015
 
Objetos que forman diferentes tipos de ángulos
Objetos que forman diferentes tipos de ángulosObjetos que forman diferentes tipos de ángulos
Objetos que forman diferentes tipos de ángulos
 
తెలుగు అచ్చులు (Telugu Achulu)
తెలుగు అచ్చులు (Telugu Achulu)తెలుగు అచ్చులు (Telugu Achulu)
తెలుగు అచ్చులు (Telugu Achulu)
 

Similaire à 12 object oriented programming

Oop by edgar lagman jr
Oop by edgar lagman jr Oop by edgar lagman jr
Oop by edgar lagman jr
Jun-jun Lagman
 
Object oriented basics
Object oriented basicsObject oriented basics
Object oriented basics
vamshimahi
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Concepts
thinkphp
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
Kumar
 

Similaire à 12 object oriented programming (20)

Oop
OopOop
Oop
 
Unit 3
Unit 3Unit 3
Unit 3
 
Oop by edgar lagman jr
Oop by edgar lagman jr Oop by edgar lagman jr
Oop by edgar lagman jr
 
Object oriented basics
Object oriented basicsObject oriented basics
Object oriented basics
 
Data Structure Interview Questions & Answers
Data Structure Interview Questions & AnswersData Structure Interview Questions & Answers
Data Structure Interview Questions & Answers
 
C#
C#C#
C#
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Concepts
 
OOPs in Java
OOPs in JavaOOPs in Java
OOPs in Java
 
core_java.ppt
core_java.pptcore_java.ppt
core_java.ppt
 
Abap object-oriented-programming-tutorials
Abap object-oriented-programming-tutorialsAbap object-oriented-programming-tutorials
Abap object-oriented-programming-tutorials
 
12th ip CBSE chapter 4 oop in java notes complete
12th ip CBSE  chapter 4 oop in java notes complete12th ip CBSE  chapter 4 oop in java notes complete
12th ip CBSE chapter 4 oop in java notes complete
 
Java interview questions and answers
Java interview questions and answersJava interview questions and answers
Java interview questions and answers
 
Java interview questions
Java interview questionsJava interview questions
Java interview questions
 
C# interview quesions
C# interview quesionsC# interview quesions
C# interview quesions
 
SAP ABAP Latest Interview Questions with Answers by Garuda Trainings
SAP ABAP Latest Interview Questions with Answers by Garuda TrainingsSAP ABAP Latest Interview Questions with Answers by Garuda Trainings
SAP ABAP Latest Interview Questions with Answers by Garuda Trainings
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Java Notes
Java NotesJava Notes
Java Notes
 
Unit 1 Java
Unit 1 JavaUnit 1 Java
Unit 1 Java
 
OOP Introduction with java programming language
OOP Introduction with java programming languageOOP Introduction with java programming language
OOP Introduction with java programming language
 
JavaHTP6e_10.ppt
JavaHTP6e_10.pptJavaHTP6e_10.ppt
JavaHTP6e_10.ppt
 

Plus de jigeno

Basic introduction to ms access
Basic introduction to ms accessBasic introduction to ms access
Basic introduction to ms access
jigeno
 
16 logical programming
16 logical programming16 logical programming
16 logical programming
jigeno
 
15 functional programming
15 functional programming15 functional programming
15 functional programming
jigeno
 
15 functional programming
15 functional programming15 functional programming
15 functional programming
jigeno
 
14 exception handling
14 exception handling14 exception handling
14 exception handling
jigeno
 
13 concurrency
13 concurrency13 concurrency
13 concurrency
jigeno
 
11 abstract data types
11 abstract data types11 abstract data types
11 abstract data types
jigeno
 
9 subprograms
9 subprograms9 subprograms
9 subprograms
jigeno
 
8 statement-level control structure
8 statement-level control structure8 statement-level control structure
8 statement-level control structure
jigeno
 
7 expressions and assignment statements
7 expressions and assignment statements7 expressions and assignment statements
7 expressions and assignment statements
jigeno
 
6 data types
6 data types6 data types
6 data types
jigeno
 
5 names
5 names5 names
5 names
jigeno
 
4 lexical and syntax analysis
4 lexical and syntax analysis4 lexical and syntax analysis
4 lexical and syntax analysis
jigeno
 
3 describing syntax and semantics
3 describing syntax and semantics3 describing syntax and semantics
3 describing syntax and semantics
jigeno
 
2 evolution of the major programming languages
2 evolution of the major programming languages2 evolution of the major programming languages
2 evolution of the major programming languages
jigeno
 
1 preliminaries
1 preliminaries1 preliminaries
1 preliminaries
jigeno
 
Access2007 m2
Access2007 m2Access2007 m2
Access2007 m2
jigeno
 
Access2007 m1
Access2007 m1Access2007 m1
Access2007 m1
jigeno
 

Plus de jigeno (20)

Access2007 part1
Access2007 part1Access2007 part1
Access2007 part1
 
Basic introduction to ms access
Basic introduction to ms accessBasic introduction to ms access
Basic introduction to ms access
 
Bsit1
Bsit1Bsit1
Bsit1
 
16 logical programming
16 logical programming16 logical programming
16 logical programming
 
15 functional programming
15 functional programming15 functional programming
15 functional programming
 
15 functional programming
15 functional programming15 functional programming
15 functional programming
 
14 exception handling
14 exception handling14 exception handling
14 exception handling
 
13 concurrency
13 concurrency13 concurrency
13 concurrency
 
11 abstract data types
11 abstract data types11 abstract data types
11 abstract data types
 
9 subprograms
9 subprograms9 subprograms
9 subprograms
 
8 statement-level control structure
8 statement-level control structure8 statement-level control structure
8 statement-level control structure
 
7 expressions and assignment statements
7 expressions and assignment statements7 expressions and assignment statements
7 expressions and assignment statements
 
6 data types
6 data types6 data types
6 data types
 
5 names
5 names5 names
5 names
 
4 lexical and syntax analysis
4 lexical and syntax analysis4 lexical and syntax analysis
4 lexical and syntax analysis
 
3 describing syntax and semantics
3 describing syntax and semantics3 describing syntax and semantics
3 describing syntax and semantics
 
2 evolution of the major programming languages
2 evolution of the major programming languages2 evolution of the major programming languages
2 evolution of the major programming languages
 
1 preliminaries
1 preliminaries1 preliminaries
1 preliminaries
 
Access2007 m2
Access2007 m2Access2007 m2
Access2007 m2
 
Access2007 m1
Access2007 m1Access2007 m1
Access2007 m1
 

Dernier

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Dernier (20)

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 

12 object oriented programming

  • 1. ICS 313 - Fundamentals of Programming Languages 1 12. Object-Oriented Programming 12.1 Introduction Categories of languages that support OOP: 1. OOP support is added to an existing language C++ (also supports procedural and data-oriented programming) Ada 95 (also supports procedural and data-oriented programming) CLOS (also supports functional programming) Scheme (also supports functional programming) 2. Support OOP, but have the same appearance and use the basic structure of earlier imperative languages Eiffel (not based directly on any previous language) Java (based on C++) 3. Pure OOP languages Smalltalk
  • 2. ICS 313 - Fundamentals of Programming Languages 2 12.2 Object-Oriented Programming Paradigm Evolution 1. Procedural - 1950s-1970s (procedural abstraction) 2. Data-Oriented - early 1980s (data abstraction) 3. OOP - late 1980s (Inheritance and dynamic binding) Origins of Inheritance Observations of the mid-late 1980s : Productivity increases can come from reuse Unfortunately, ADTs are difficult to reuse - never quite right All ADTs are independent and at the same level Inheritance solves both - reuse ADTs after minor changes and define classes in a hierarchy 12.2 Object-Oriented Programming (continued) OOP Definitions: ADTs are called classes Class instances are called objects A class that inherits is a derived class or a subclass The class from which another class inherits is a parent class or superclass Subprograms that define operations on objects are called methods The entire collection of methods of an object is called its message protocol or message interface Messages have two parts - a method name and the destination object In the simplest case, a class inherits all of the entities of its parent
  • 3. ICS 313 - Fundamentals of Programming Languages 3 12.2 Object-Oriented Programming (continued) Inheritance can be complicated by access controls to encapsulated entities A class can hide entities from its subclasses A class can hide entities from its clients A class can also hide entities for its clients while allowing its subclasses to see them Besides inheriting methods as is, a class can modify an inherited method The new one overrides the inherited one The method in the parent is overriden There are two kinds of variables in a class: 1. Class variables - one/class 2. Instance variables - one/object There are two kinds of methods in a class: 1. Class methods – accept messages to the class 2. Instance methods – accept messages to objects Single vs. Multiple Inheritance One disadvantage of inheritance for reuse: Creates interdependencies among classes that complicate maintenance 12.2 Object-Oriented Programming (continued) Polymorphism in OOPLs A polymorphic variable can be defined in a class that is able to reference (or point to) objects of the class and objects of any of its descendants When a class hierarchy includes classes that override methods and such methods are called through a polymorphic variable, the binding to the correct method MUST be dynamic This polymorphism simplifies the addition of new methods A virtual method is one that does not include a definition (it only defines a protocol) A virtual class is one that includes at least one virtual method A virtual class cannot be instantiated
  • 4. ICS 313 - Fundamentals of Programming Languages 4 12.2 Object-Oriented Programming (continued) Design Issues for OOPLs 1. The Exclusivity of Objects a. Everything is an object Advantage - elegance and purity Disadvantage - slow operations on simple objects (e.g., float) b. Add objects to a complete typing system Advantage - fast operations on simple objects Disadvantage - results in a confusing type system (two kinds of entities) c. Include an imperative-style typing system for primitives but make everything else objects Advantage - fast operations on simple objects and a relatively small typing system Disadvantage - still some confusion because of the two type systems 2. Are Subclasses Subtypes? Does an is-a relationship hold between a parent class object and an object of the subclass? 12.2 Object-Oriented Programming (continued) 3. Implementation and Interface Inheritance If only the interface of the parent class is visible to the subclass, it is interface inheritance Disadvantage - can result in inefficiencies If both the interface and the implementation of the parent class is visible to the subclass, it is implementation inheritance Disadvantage - changes to the parent class require recompilation of subclasses, and sometimes even modification of subclasses 4. Type Checking and Polymorphism Polymorphism may require dynamic type checking of parameters and the return value Dynamic type checking is costly and delays error detection If overriding methods are restricted to having the same parameter types and return type, the checking can be static
  • 5. ICS 313 - Fundamentals of Programming Languages 5 12.2 Object-Oriented Programming (continued) 5. Single and Multiple Inheritance Disadvantages of multiple inheritance: Language and implementation complexity (in part due to name collisions) Potential inefficiency - dynamic binding costs more with multiple inheritance (but not much) Advantage: Sometimes it is extremely convenient and valuable 6. Allocation and Deallocation of Objects From where are objects allocated? If they all live in the heap, references to them are uniform Simplifies assignment - dereferencing can be implicit Is deallocation explicit or implicit? 7. Dynamic and Static Binding Should ALL binding of messages to methods be dynamic? If none are, you lose the advantages of dynamic binding If all are, it is inefficient