Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007
Sum2000 Midterm Review: O-O Systems
(a) A class defines a set of services and attributes associated with an object. An instance is a concrete and unique object built using a class as a blueprint.
(b) A class method exists within the definition of the class, and the variables it modifies are those within the class itself, which are essentially, global. An instance method modifies the unique set of variables associated with each individual instance/object rather than for all objects.
(c) A class variable is essentially a global variable. An instance variable is private and local to the object in which it was instantiated.
(d) As I understand it, the difference between prototype-based and class-based systems is where the attributes and services are bound to the definition of a class. In a class-based system, binding occurs statically at compile time, whereas it occurs dynamically at run-time in prototype-based systems. The advantage of a class-based approach would be compile-time checking, potentially increased execution speed and a lower chance for the programmer to screw things up. A prototype-based system sacrifices that for unparalleled flexibility in manipulating objects and classes, potentially allowing for cleaner code or to shortcut otherwise tedious measures rather simply. An example of this flexibility in Smalltalk would be ProtoObject become:.
If I'm wrong on my definitions, please correct me.
Class variables aren't global. We'll introduce prototype and class based systems this morning, so you can try again later. Mark Guzdial
Definitely work on this one – it's important.
Ok, to clarify, prototype-based object systems spawn sub-instances off master-instances. Changing the master instance changes the sub-instances.
And, class variables aren't global. They're static between all instances of the same class.
Link to this Page