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

Marlena Frank

Information about me: Hi all. If you want to know more about me, please see my website: I just finished my fourth term cooping with the Mechanical Engineering Department at their Help Desk. I've programmed in SQL, ASP, PHP recently at work, and I like to plan ahead on projects and get parts done in a timely manner.

I am currently looking for a group that is preferrably also in Abowd's 9:00 class.

If you have any questions, please email me at

Marlena Frank: CoWeb Assignment 3

Using Finding Tools in Squeak

The finding tools in Squeak can be extremely useful in solving difficult bugs that come across in the code. I've found these to be indispensible tools while coding in Smalltalk.

Implementors Of...

Either by clicking 'implementors' button on the System Browser, by right-clicking on the text and choosing "implementors of", or by clicking Alt+M (for Windows) on a highlighted piece of code.
Uploaded Image: implement_1.jpg Uploaded Image: implement_2.jpg

The implementor tool can tell you one of two things. It can either tell you possible responders to a message, or alternative implementors of a method. For example, say you were examining a type of morph, the HeadMorph class and you wanted to find out if one of the methods, say step, was used in any other class. If you look at the implementors of step, you are given a listing of all classes that have the step method, including Morph and HeadMorph as well.
Uploaded Image: implement_3.jpg

Senders Of...

Similar to the Implementors tool, you can either click on the 'senders' button on the System Browser, right-click on the text and choose "senders of", or by clicking Alt+N (for Windows) on a highlighted piece of code.
Uploaded Image: senders_1.jpg Uploaded Image: senders_2.jpg

The senders tool shows you any other classes that might call the method you've highlighted. So instead of showing you classes that have the method you have highlighted (as in the implementor tool), you get a listing of methods that call the method you have highlighted. So going back to our previous example, we'll look for any methods that call the defaultColor method. We get a listing of methods that call the defaultColor method, including the Morph's initialize method. From this we can determine that the HeadMorph gets its default color from calling "super initialize" in its initialize method.
Uploaded Image: senders_3.jpg

The Method Finder

You can open the Method Finder from two ways. You can either click in the world, go to "Open...", and scroll down to "Method Finder", or you can open the Tools tab on the right side of the screen and drag a Method Finder icon onto the screen.
Uploaded Image: methodfinder_1.jpg Uploaded Image: methodfinder_2.jpg

The method finder tool is perhaps one of the most useful debugging tools in Squeak. It allows you to do a whole-system search for any method. It's great to get started trying to figure out how to create something. Suppose that you wanted to find a way to choose the default color of the HeadMorph. You could do a search for "colorpick" in the method finder, and you would get a list of every method and class in Squeak that includes colorpick. By clicking on method names in the bottom window you can see what class the method is called in in the right window. By clicking on those listings in the right window, a System Browser is opened for that Class.
Uploaded Image: methodfinder_3.jpg

Midterm Review

Class-Based Inheritance

What's the difference between a class/instance?
A Class can be described as the definitions of attributes and services to be reused later on.

So lets see an example of this. Suppose we were going to make a dog class:
Uploaded Image: dog1.jpg

You see that not only do all dogs have a name, but that they can also chase their tails and lick themselves.
OK, now that we have our class, lets make some instances of it. These instances will still be Dogs, of course, and they will also have the same abilities as dogs. They'll have a name, they'll be able to chase themselves, and of course, lick themselves.

Jack <- Dog new.

Uploaded Image: dogcollar.jpg
Suzy <- Dog new.

Uploaded Image: pinkbow.jpg

What is the difference between class/instance variables?
Well, since Jack has a collar, we'll give him a method to let him lick his collar.
Jack lickCollar.

Isn't he cute? Ok, well Suzy doesn't have a collar to lick, but she does have a bow. So we can add a method for her as well.
Suzy poseWithBow.

So let's doublecheck ourselves. Jack is a Dog and he has a collar. Suzy is also a Dog and has a bow. They both also have individual interactions with those instance variables as well. Now Jack can't interact with a bow because not all Dogs have bows and instance variables are only available within the instance.

Now lets discuss more on class variables, which are very different from instance variables. Lets go back to our Dog class and add the class variable owner. By doing this we are making all dogs not only have an owner, but they have a particular owner. Lets see how this works...
Uploaded Image: dog2.jpg

Ok, now lets set Jack's owner to be Andy.
Uploaded Image: andygriffith.gif
Jack setOwner: Andy.

Alright, that worked well. Now lets set Suzy's owner.
Uploaded Image: barneyfife.jpg
Suzy setOwner: Barney.

But when we go back to see Jack's owner, we get... Barney! By changing the owner through the instances of Dog we've changed the owner for all Dogs in our system. Class variables have values that are shared by all instances of a particular class.

How do class/instance methods work in Smalltalk?
A Class Method in Smalltalk:
Jack <- Dog new.

An Instance Method in Smalltalk
Jack chaseTail.
Suzy chaseTail.
Jack lickCollar.
Suzy poseWithBow.

Midterm Review

Tracing Code

| data onlyPositiveNumbers |
data := OrderedCollection withAll: #(1 2 3 -4 -5 'error' 6 -7 999 2).
onlyPositiveNumbers := [:i | (i isKindOf: Number) and: [i positive]].
data := data select: onlyPositiveNumbers.
data := data copyUpTo: 999. "not including"
Transcript show: data average

We'll go through this code line by line so that we can find out exactly what's going on.

| data onlyPositiveNumbers |

data := OrderedCollection withAll: #(1 2 3 -4 -5 'error' 6 -7 999 2).

onlyPositiveNumbers := [:i | (i isKindOf: Number) and: [i positive]].

data := data select: onlyPositiveNumbers.

data := data copyUpTo: 999. "not including"

Transcript show: data average

Dog silhouette image:
Andy Griffeth image:
Barney Fife image:
Jack image:
Suzy image:

Used this site for inspiration:

Link to this Page