Object Model Flashcards
Where is the method table stored?
The class representation, namely the class object.
Why do we need a class tun-time representation?
- dynamic binding
- Run-time type info
- Reflection
What is reflection?
The ability of the program to examine and possibly modify itself
what is serialization?
Serialization is the process of turning an object in memory into a stream of bytes so you can do stuff like store it on disk or send it over the network.
What is a meta-class?
a class whose instances are classes
What’s a terminal instance?
cannot be instantiated further
What is a 1-level system?
Object only.
object describe themselves, no classes: objects can be instantiated from other objects and inherited from them.
an object is essentially a map from names (strings) to values or methods.
Example: Javascript, Self
What is prototype inheritance?
קישור בזמן-ריצה במקום
subclassing
בזמן הידור
1-level pros and cons
Pros:
- Extremely flexible
- As Object Oriented as it gets… (literally)
Cons:
- Performance penalty on member lookup (need to go to all the “parents” and look there)
- No compile time validations and optimizations (everything is done dynamically)
- Not very common
What is the 2-level system?
- Objects are instances of classes
- Classes are compile time creatures
(No runtime representation) - Minimal runtime overhead
Zero overhead (“supermarket”) principle
But object types cannot always be determined
On some cases, run-time type information is available - No class (static) members
What is the 3-level system?
- Objects are instances of classes
- Classes are also objects
- All classes are instances of one metaclass
Can a user-defined class affect the Class object or the meta-class in a 3-level system?
A user-defined class can only affect class objects state (for example, diffrent method dictionary for every user-class).
object members are defined in the object's class. in a 3-level system where are class members defined?
They should be defined in the meta-class, but there is only one so it's not possible. we can emulate class members with static members since the are stored in some global space.
What is the 4-level system?
Each object is an instance of a class Each class is an instance of a metaclass Each metaclass is an instance of a meta-metaclass One meta-metaclass (instance of itself and inherits from Object or Class)
What is the 5-level system?
Same as 4-level, except meta-metaclass (we'll call Metaclass) is and instance of metaclass class and metaclass class is instance of Metaclass.