Chapter 12 Flashcards
Which languages are considered pure OOP languages?
Smalltalk + Ruby
What must any OOP language support?
ADTs
Inheritance
Polymorphism
What is good about inheritance?
Increases productivity from reuse
Problem with basic ADTs?
Difficult to reuse without some changes
What are some OO concepts?
ADTs aka classes
Class instances aka objects
Class inheritance aka subclass/ derived class + superclass . parent class
Subprograms defining operations on objects aka methods aka member functions
Call to methods aka messages
Collection of object methods aka message interface
2 part messages aka method name + destination object (myObject.print(12))
Access control in inheritance
Overriding methods
What are the 2 kinds of variables in a class?
Class variable ( one per class )
Instance variables ( one per object )
Same with methods
Disadvantage of inheritance?
Complicate maintenance, interdependencies among classes
What type of binding is a polymorphic reference?
Dynamic Binding
What is a abstract method?
Only define protocol, no definition
What is a abstract class?
Include at least one abstract method
Cannot be instantiated
What are some design issues for OOP languages?
Single vs multiple inheritance
Dynamic vs static binding
Nested classes
Are subclasses subtypes?
What is good and bad when everything is an object?
Good: Elegance + pure uniformity
bad: simple operations are slow
What is good and bad about adding objects to a complete typing system?
Good: simple operations are fast
Bad: Results in confusing type system
Good and Bad about using imperative typing system for primitives and making everything else objects? (Java)
Good: Simple operations are fast, but typing system remains relatively small
Bad: 2 type systems have to mix
When is a derived class a subtype?
If is has a “is-a” relationship with the parent class
Good and Bad of Multiple inheritance?
Good: convenient + valuable
Bad: Complexity, name collisions. potential inefficiency
What is the problem with diamond inheritance?
It always produces a type problem
Should every binding of a message to a method be dynamic?
Only dynamic binding is inefficient
No dynamic binding = no advantages
What is a problem with nested classes?
Deciding visibility of members
When do you use nested classes?
When a new class is only needed by one class
What are the 2 object initialization types?
Explicit and implicit( only if there exists a default constructor in the language )
This can also lead to explicit + implicit initialization of subclass objects
Does Smalltalk have any characteristics of imperative languages?
No. Its a pure OOP language
How are objects accessed in Smalltalk?
Typeless reference variables
Is Smalltalk deallocation implicit or explicit?
implicit
Uses a garbage collector which can be slow