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

Ben Hartmann

Coweb 2

Monticello is a tool that allows teams to use a repository to share code. It is embedded so that code transfer can be done completely inside squeak.

First, you must open monticello in Squeak. Open a worldmenu, then select open... > Monticello Browser. If Monticello browser does not appear here, you must install it.

Next, you must add a package to the repository. This is done by pressing "Package+". The name of the package you wish to share is entered. This places the package in the left frame.

Third, you must add a repository with the "Repository+" button. Here, you must choose the type of server the repository is, and the login information. This will place a new repository in the right frame.

After you have selected a package and repository, you are ready to save and load. Clicking the "save" button will allow you to name the build and add a log message. Pressing the "open" button lets you view all of the changes available.

In the repository window, there are many commands available to you. "Refresh" refreshes the list, "browse" shows you the actual package code, "History" shows the previous versions that have been commited to the repository, and "Diff" shows the differences between a package and previous versions.

When loading someone else's code, the most straight forward way of doing it is with the "Load" button. This will REPLACE ANY CLASSES in your enviroment with classes in the imported package. This option should only be used if you have nothing you would like to save in your squeak image.

Another way to load new code is the "Changes" button. this shows a list of all the differences between your local classes and the classes inside the repository. Each change that you want brought into your enviroment can be right clicked and "installed". In this way, you are able to install changes on a per method basis, not per class. Unfortuneately, this method is fairly tedious, but it saves a lot of agrivation of overwriting your hard work.

One possible final way to update code is the "merge" button. When our group tried using this, there was a bug, so it never worked on our image. However, it is assumed that merge will automatically install all the changes into your image. This function is not reliable however.

One other bug we ran into is that sometimes a 530 Login error will occur. The best solution to this bug is to try again. If it continues to appear, then either the repository info is wrong or the repository server is unavailable.

Uploaded Image: monticello.JPG

Coweb 1

Class-Based Inheritance (1 point)
What is a class? A class is a set of instructions and rules by which an object behaves.
What is an instance? An instance is one of the objects that can be created based on a classes' instructions and rules. Objects are independant of each other.
How do the two relate? A class is a definition by which instances can be created.
In Smalltalk, what is the difference between class variables and instance variables? Class variables are shared between all objects of that class. Instance variables are unique per instance.
In Smalltalk, what is the difference between class and instance methods. Class methods are called on the class and can be called statically, meaning no single instance has that method. Instance methods are inside of all instances, but when called, are only executed on that particular instance, and the results usually only affect that instance.

Message Passing (1 point)
What is message passing and how does it fit into the way you program in Smalltalk? Message passing is the behavior where one object can send a message to another object in order to achieve some goal (Much like methods). Since everything in Squeak is an object, everything communicates by passing messages. In order to find out 5 x 5, you send the object '5' the message 'x 5' and it will return to you the object '25'.
How does message passing work together with the class-based inheritance? A class is defined by what kinds of messages it can send and recieve. Instances of the class then are able to send and receive those messages. If a message is passed to an instance and it does not know what to do with it, it can ask its parent class, etc.
What are some of the advantages and disadvantages of method passing? Advantages: Fully OO design. Conceptually easier to understand. Disadvantages: Slow as hell. Annoyingly hard to debug. If a message doesn't exist, it can still be given to an object.

Tracing Code (1 point)
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?

| data onlyPositiveNumbers |
This line creates 2 instance variables: data and onlyPositiveNumbers. Variables never have a type associated (all hold objects)

data := OrderedCollection withAll: #(1 2 3 -4 -5 'error' 6 -7 999 2).
data is assigned to an object(after object is determined i.e. lastly). OrderedCollection is a class. withAll: is a class message that creates an instance of an OrderedCollection. #(x x x x x x) defines a set of objects that will be passed into the parameter of withAll: the Period means end of line.

onlyPositiveNumbers := [:i | (i isKindOf: Number) and: [i positive]].
onlyPositiveNumbers is assigned to an object (after object is determined). []signifies a block of code and is an object. The lines inside: object i is sent message isKindOf: with param Number and will return a boolean. object i is again sent a message 'positive' and returns a boolean. The final data is 'boolean' and: 'boolean', which is sending a boolean the message 'and:' with a boolean parameter. That will return true or false.

data := data select: onlyPositiveNumbers.
data is assigned to an object. the original data object is sent the message select: with the param onlyPositiveNumbers. This object is actually the previous block of code that will return a boolean number. With each data in the data set, (assigned in the second line,) that item will be set as the i variable in the block of code previously and if it returns true, will be included in the new data object.

data := data copyUpTo: 999. "not including"
data is assigned to an object. original data object is sent the message copyUpTo: 999. the "not including" is a comment.

Transcript show: data average
data is sent an 'average' message. The resulting object is a parameter in the show: method being passed to Transcript.

Link to this Page