View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

Discussion 4 - Samuel Young

Spring 2004 Midterm #1

O-O Systems

A class is a set of instructions that define an object. It is like a blueprint for the object. An instance is an actual, existing object. It is an entity in and of itself and follows the blueprint provided by its class.
An class method is associated with the class and does not directly affect any instance of an object. It may be called by asserting only the class name. On the other hand, an instance method alters the behavior of an actual instance of an object. It may only be called through an instance of an object.
A class variable exists across all instances of a given class. If class A has a class variable Var, all instances of A objects share the same Var field. On the other hand, instance variables are specific to each instance of an object and do not exist unless an instance is created. If class A defines an instance variable X, then an instance of A named One and and instance of A named Two have distinctly different variables X and X respective values are not related.

'new' is a class method. The class Box is the only assertion required to send the message 'new'. 'new' is sent to class Box, and class Box creates and returns an instance of itself.

'initialize' is an instance method. Since 'new' returns an instance of class Box, it is this instance (not the class) that is sent the 'initialize' message.

Link to this Page