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 - Brandon Reynolds

1. What's a class? What's an instance?
2. What's the difference between a class and instance method?
3. What's the difference between a class and instance variable?
4. In the following Squeak code what type of method (class or instance) is "new" and what type is "initialize"?


joe := Box new initialize

1. What's a class? What's an instance?
A class is a 'container' for a set of variables and methods that define an object. It could be considered in the form of a 'noun,' something that has a set of traits and actions it can perform. An instance is the generation of a class, an object that can interact with other objects and perform the actions assigned to it.

2. What's the difference between a class and instance method?
A class method is one that affects the class in its entirety, rather than only an instantiation. An instance method affects only an instantiation of the class, and those changes are lost when the object is disposed of.

3. What's the difference between a class and instance variable?
A class variable is one that belongs to the entrie class itself, and is associated with the class name. An instance variable is one that is generated every time the object is instantiated, and is lost upon destruction.

4. What type of method is "new" and what type is "initialize"?
New is a class method, as it pertains to the entire Box class, whereas initialize is an instance method, for it only affects an instantiation.

Link to this Page