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

Brian Henke

Collection Classes:

1) How do OrderedCollection and Set differ?
Sets contain no duplicates; whereas OrderedCollection allows for duplicate values. OrderedCollections are arrays that grow accordingly when data is added to it.

2) How do OrderedCollection and Array differ? Why would you use one over the other?
OrderedCollection is basically an Array, but grows as necessary. You would use an array if you knew the size isn't going to change rapidly throughout the program.

3) How do you use a Dictionary? Why is accessing a Dictionary so fast?
A Dictionary is used like a hash table by looking up keys to quickly access certain values. This function allows you to directly access the desired value and bypass most other data.

Message Passing
1) What is message passing and how does it fit into the way you program in Smalltalk?
You send a message to an object perform methods. When you pass a message it triggers a method.

2) How does message passing work together with the class-based inheritance?
messages can be used to call methods that are defined for superclasses of a particular object. The message is passed up the heirarchy until the method is found or an error is thrown.

3) What are some of the advantages and disadvantages of message passing?
The advantage of message passing is that all computation is performed in the same way. One of the disadvantages is that when doing mathematical computations Smalltalk does not understand order of operations because it simply passes the messages as they are read from left to right.

Tool Description

The debugger tool is extremely useful for tracking down problems that arise in code. The programmer always seems to slip up in tiny areas that can become hard to track down in larger projects. The top window contains a stack trace that allows you to step through the various method trees. There is stepping through, into, over, etc. that allows dynamic flow control. The debugger also allows coding in the bottom window which is great for changing code on the fly.

Uploaded Image: Debugger.JPG

Class-Based Inheritance (1 point)

What is a class?
A class is a model, pattern or blueprint from which an object is created. They are structured from actual objects you would find in real life, such as a clock, timer, second hand, etc.

What is an instance?
An instance is a separable collection of variables and methods defined by a class.

How do the two relate?
Every object is an instance of a class. The class defines the instances.

In Smalltalk, what is the difference between class variables and instance variables?
Class variables in smalltalk are variables that belong to a class and not the individual instances themselves. Instance variables belong to the instances and are different for each one.

In Smalltalk, what is the difference between class and instance methods?
Class methods in smalltalk are methods that belong to the actual class, not the individual instances themselves. Instance methods belong to the instances and can interact with each the instance variables that it belongs with that instance.

Writing Code (1 point)

fib: num
"Computes the Fibonacci of a number."
	(num isKindOf: Integer) ifFalse: 
		[^self error: 'Invalid input'].
	num < 0 ifTrue: [^self error: 'Invalid number'].
	num = 0 ifTrue: [^1].
	num = 1 ifTrue: [^1].
	^(self fib:(num-1)) + (self fib:(num-2)).

Links to this Page