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

Will Blatt

William Blatt – gtg785r

CoWeb Assignment 1

1. Tracing Code:

| data onlyPositiveNumbers |
Creates two temporary variables for the method.
data currently holds nil.

data := OrderedCollection withAll: #(1 2 3 -4 -5 'error' 6 -7 999 2).
Creates a new instance of OrderedCollection with the elements listed, and stores that collection in the variable data. It's worth noting that unlike arrays from Java/C (among many other languages), OrderedCollection is non-homogeneous. This means it is fine to have an OrderedCollection with elements of different types.
data currently holds an OrderedCollection of elements (in order): 1, 2, 3, -4, -5, 'error', 6, -7, 999, 2

onlyPositiveNumbers := [:i | (i isKindOf: Number) and: [i positive]].
Creates a block of code (which is an object in Smalltalk) that, when used, will sort through all possible i values the block of code is being asked to scan. It will return a Boolean object for true or false depending on whether the value i meets the conditions (being a positive number).
data is unchanged from before.

data := data select: onlyPositiveNumbers.
The select method of OrderedCollection creates a new OrderedCollection containing only the elements that satisfy the block of code passed as a message to the method. This new OrderedCollection is then set to the variable data.
data currently holds an OrderedCollection of elements: 1, 2, 3, 6, 999, 2

data := data copyUpTo: 999. "not including"
The copyUpTo method creates a new OrderedCollection containing all the elements of the original OrderedCollection in order until it finds a copy of the object being passed as a message (in this case 999). Again, this new OrderedCollection is being set to data.
data currently holds an OrderedCollection of elements: 1, 2, 3, 6

Transcript show: data average
Displays the average of the elements of the OrderedCollection on the Transcript. data average returns 3, so this is what is printed.
data is unchanged from before.

Writing Code:

   (self < 0) ifTrue: [self error: 'cannot execute factorial on negative integers'].
   (self = 0) ifTrue: [^1].
   (self > 0) ifTrue: [^self * ((self - 1) factorial)]

^^^ Haha, when I did CA1, I assumed that the coding example was also from last semester's test. Oops...

CoWeb Assignment 2 - Using Finding Tools

Each of the tools for finding methods and implementors inside Squeak were very valuable to our group during our project considering they often represented the most efficient ways for us to find classes or methods we needed.

The implementors of... tool was useful in situations where we were using the Kernel classes and came across methods we didn't recognize. By clicking on Implementors and selecting the method name, it lists all of the classes that provide that method. The only complaint about this feature is that sometimes there are method names that are used in dozens of otherwise unrelated classes, making it difficult to find which one you really want in those cases.

For us, the senders of... tool was not as important when dealing with provided code but very important when handling our own. For example, if we made a serious change to the way a method worked, we could click Senders in a Browser window and select the method we just edited to find other methods that also used it. This helped simplify the testing process because we knew where to expect changes to occur.

Out of the three, the Method Finder was to me the handiest of the tools that Squeak provides. The finder is found in the Open submenu from the World menu. It is most useful when you are searching for something that you know should already be implemented, yet you're not sure of the class you're looking for.

Uploaded Image: lookatmeusesqueak.jpg

Me using all the features of Squeak... all at once! :)

Coweb Assignment 3 - Analysis and Design

Uploaded Image: crc1.jpg Uploaded Image: crc2.jpg Uploaded Image: crc3.jpg

Uploaded Image: uml.jpg

Links to this Page