Chapter 12 - OO Concepts Flashcards
which PL serves as the originator of OO programming
SIMULA 67
3 benefits of inheritance
- a new ADT can “inherit” some or all of its data and behavior from an existing type and modify that type without affecting it
- allows for code reuse without harming original
- is hierarchical in nature and well suited to modeling descendant relationships
what is a derived class?
the class defined using inheritance (subclass is not entirely accurate)
what is a parent class?
the class being inherited from (superclass isn’t entirely accurate)
what is a message protocol or message interface
the entire collection of methods of an object
message passing vs subroutine call
message passing implies a request to an object to execute one of its methods that partially entails operating on the object itself
subroutines typically process data sent by the caller
class variables/methods vs instance variables/methods
class variables/methods only have one copy per class and are shared by all instance of the class
instance variables/methods have one copy for each instance of the class and are only used by the instance to which they belong
1 disadvantage of inheritance
creates interdependencies among classes that complicate maintenance
what is dynamic dispatch?
the dynamic binding of messages to method definitions. AKA the messages are statically coded but the receiving object is determined at runtime.
This creates polymorphism of sorts
What is the way in which dynamic dispatch is most often implemented?
through abstract methods (pure virtual methods in C++)
8 design issues for OO PLs
- the exclusivity of objects
- are subclasses subtypes
- type checking and polymorphism
- single or multiple inheritance allowed
- allocation and deallocation of objects
- dynamic and static binding
- nested classes
- object initialization
What does “exclusivity of objects” mean
it refers to how objects are used in the PL and what kinds of data are represented by objects
3 approaches to the exclusivity of objects
- everything is an object (Ruby)
- add objects to a complete typing system (C++)
- include an imperative-style typing system for primitives but make everything else objects (Java)
1 advantage and 1 disadvantage to everything as an object exclusivity approach
Adv: elegance and purity
dis: slow operations on simple objects
1 advantage and 1 disadvantage of adding objects to complete typing system exclusivity approach
adv: fast operations on simple objects
dis: results in a confusing type system