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

Michael Noonan

Mike Noonan - gtg708y

CoWeb Assignment 2: Using ChangeSets

When it comes to saving and sharing your code there are quite a few ways to do this. The more classes you edit, especially outside of your own category, ther more handy changesets become.

For this semesters project, most people worked with FaceMoprph, and I bet most people made changes to that class or similar ones.
If you return to your category, where you are writing most of your code, and then try to file out, that .st will not have any of the changes you made to FaceMorph or any other classes outside of your category.

You could go and file out individual classes from FaceMorph and each class you changed outside, or you could simply use changesets.

It is best to start a changeset off a fresh image, therefore you wont get any weird changes you didnt want included.
So, off a fresh image, you can either start fresh coding, or file in some of your team mates work. Now once you have made some changes you are ready to start and/or file out your changeset.

To open the simple change set sorter left click for the world menu and click on open, you will see something like this:

Uploaded Image: coweb2_1.gif

select simple change sorter and then you will have something that looks like this:

Uploaded Image: coweb2_2.gif

you can rigth click your unnamed change set and rename it.
if you want to go ahead and file out right click and you will see this:

Uploaded Image: coweb2_3.gif

you file in a changeset exactly the same way you file in an .st

Now as you continue coding you can always make updates and file out a new changeset. This will only contain the changes you have made.
if you were to create a changeset named myChangeSet...this is what your directory might look like after you have filed out a few versions of your changeset.


you can also choose to rename your changeset if all the numbers get confusing.

Another cool feature is the dual changeset sorter.
You can load up multiple changesets and view their differences
in code changes and what not. This is nice because you can look at the code and copy a method or class from one side (one changeset) to another.

CoWeb Assignment 1:

What is a class? What is an instance? How do the two relate? In Smalltalk, what is the difference between class variables and instance variables? In Smalltalk, what is the difference between class and instance methods.

A class is a grouping of related variables and methods that have serve a particular function.
In otherwords, a class is a way to represent a particular object.
An instance is a single live object that is holding data or performing a task in the program.
The two relate in the sense that, an instance is a class. A class is written by the programmer, and when the program is running a class becomes an instance while it is alive(or being used by the program). A class can have one or many instances of itself while running.

To relate an instance to real life, take an object...say a bird. If you make a bird class that knows and does bird things, while your program is running you can have many instances of "birds", just like as if you were to look outside and see many birds flying. Each bird is its own entity, but it is still a bird.

Class variables are shared throughout the whole class and can be cross-refrenced from all methods in that class, where as instance variables exist only when a particular method is being run.
Class methods are associated with an entire class, where as instance methods are associated with specific objects which are instances of that class.

The following code solves the rainfall problem, which you may have seen in previous CS classes. For each line, describe what the Smalltalk code does. Be as specific as possible. In particular, what is data at the various points in the code?

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

Line 1 is just the basic variable declaration.
Line 2 is creating an ordered collection.

here is what data looks like (1,2,3,4,-5,'error',6,-7,99,20).
Line 3 is like a filter that only takes numbers (not strings) and ensures those numbers are > 0.
Line 4 is implementing this filter on the ordered data set (using select:)

here is what data looks like after the filter (1,2,3,6,999,2).
Line 5 using (copyUpTo) will take that set, and make a copy up to 999.

here is the data set now (1,2,3,6).
Line 6 prints the datas average, which is (12/4) which is 3.

Link to this Page