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

Daniel Vargas

Uploaded Image: velociraptor_daniel.jpg

Coweb Assignment 3 – Final Exam Review

History of Object Oriented Programming (1 point)
Alan Kay was the first to see objects as the future of computer science. He came
up with the idea of Flex, an object oriented personal computer, which was a radical
idea at the time. He envisioned the personal computer as a learning tool and a
meta-medium. Alan Kay is also one of the major creators of Smalltalk and Squeak.
Kay's contributions led to the mainstream use of the mouse/GUI combination as in
smalltalk. He was also one of the first major proponents of object oriented
design. The dynabook, a device similar to today's tablet PC's was the goal of
smalltalk. Clearly, Alan Kay's vision was well ahead of his time.

Ivan Sutherland was the creator of a drawing program called sketchpad (1963).
Sketchpad was the first object oriented drawing program. It would allow for
"master" and "instance" drawings, in which the instance drawings would share the
property of the master drawing (ie adding a window in a drawing of the master house
would add a window in all the instance houses). Sutherland's contributions to
early object oriented programming inspired Alan Kay in his research.

Garbage Collection (3 points)
What are the advantages and disadvantages to using garbage collection?
Advantages: Automatic GC eases programmer burden and adds security and safety.
Having automatic GC means that the programmer can worry more about relevant code
and less about freeing allocated memory and other such related tasks
Disadvantages: Performance and Control. Without GC, there is no wasted time scanning
the heap for things no longer needed. Also, there is far more control for the
programmer as to what is garbage collected.

Explain how reference counting works. Include an example.
Reference counting keeps count of all references to an object. As references are
added/removed, this number is increased/decreased. For example, lets say there exists
an ant farm system. When an ant is created, the ant farm has a reference to it.
While the ant exists, its reference number is 1. Once the ant dies, the reference
that the ant farm has no longer exists, and the ants number is decreased to 0. During
the next GC, this object can now be deleted.

Explain how mark and sweep works. Include an example.
Mark and sweep maintains bits to mark an object as white, grey or black. All objects
start out as white (deletion candidates), black (do not delete), or grey (unknown).
The objects that black have references to are greyed. These grey objects are then
blackened and the objects they have references to are greyed. The process continues
until the grey set is empty. The whites are then deleted. Lets say we have an
ant farm system. The system can recognize larger/older/major parts as black. Lets say
that the ant farm itself is eventually blackened. The references it has are then also
blackened. Things that are no longer referenced by the ant farm that used to be black
can be white during this sweep and are then deleted.

What problems of garbage collection do generational scavenging and “stop and copy” address?
How do they address them?
Generational scavenging and stop and copy address the problem of memory fragmentation that
is present in other methods. The way that generational scavenging and stop and copy combat
this is by creating several sections in memory for special things.
In generational scavenging, there exist several sections that are devoted to objects in a
specific age range. The theory behind this is that older objects are less likely candidates
for GC and do not need to be scanned as often as newer objects. When a region becomes
full in this process, it is promoted to a new region and added there sequentially.
This old region is overwritten with new objects, also sequentially. The sequential
proccess eliminates fragmentation.
In stop and copy, there exist two sections in memory. One is labeled as active, and one
as inactive. When a garbage collect is neccesary, all live objects in active region
are moved into the inactive region sequentially. The inactive region then becomes the
active region and then inactive region can be overwritten/garbage collected. Since
the live objects are put into memory in continuous spaces in memory, it defragments it.

Coweb Assignment 2:

Finding Tools

Squeak has many built in tools for finding code in the system that make it easier for
the programmer to understand how the code written works and also to simply find
"hidden" methods/code.

Implementors of...

The implementors button is located in the browser as the third button from the left in
the row of buttons.

This function allows the user to see what classes have that specific method in them.
For instance, one can click on the implementors button in the below message in facemorph
to see what other classes have a "drawOn: aCanvas" method inside of them. From this,
the programmer can learn how other morphs draw themselves.


Senders of...

The senders button is also located in the browser just to the left of the implementors
button. This button is useful for finding out from where a message call is occuring.
It becomes useful for debugging a larger project when the user cannot find from when/where
a message call is happening. Clicking on this button will provide the user with a list
of appropriate messages to choose from, followed by a listof senders.

The message finder...

The message finder can be found by clicking on the world, followed by "open" in the menu
followed by "message finder."

The message finder is useful when trying to find code to do something that is built into
the system. For instance, if the user wanted to find any code related to MPEG playback,
he/she would simply type "MPEG" in the top left box followed by alt-s (on windows) to
accept the imput. This results in several message names related to the query appearing
in the box just below the search box. Clicking on these messages reveals a list of
implementors of the message to the right which can then be clicked on and browsed.

Included in the messages box are also several classes related to MPEG, such as
MPEGMoviePlayerMorph and MPEGPlayer which can also be browsed by the user.

Uploaded Image: squeakcoweb.GIF


Coweb Assignment 1:
Class-Based Inheritance
What is a class?
A class is a blueprint on how to build an instance.
Classes usually represent real life objects, like Dog or Cat.
Classes are used to group definitions of attributes and services.
Classes also provide pieces to reuse.
What is an instance?
An instance is a way to describe any object. Every object is an instance
of some class. For example, 13 is an instance of SmallInteger, etc.

How do the two relate?
The two are related because every object is an instance of a class.
Technically, classes are instances too. Each class has its own metaclass.
Each class is an instance of its metaclass.

In Smalltalk, what is the difference between class variables and instance variables?
Class variables in smalltalk are like static variables in java. These variables
are specific to the actual class, not the instance. Instance variables share the same
name from instance to instance of a class, but are different objects and thus
can contain different data.

In Smalltalk, what is the difference between class and instance methods?
Class methods are specific to the actual class, not the instance. Therefore,
instances cannot respond to class methods as in java. Classes respond only to
a message that is a class method. Instances respond only to instance method
messages.

Writing Code:
fib: num
	(num < 0) ifTrue: [
		^'Invalid input'.
	].
	(num = 0) ifTrue: [
		^1.
	].
	(num = 1) ifTrue: [
		^1.
	].
	^(self fib:(num-1)) + (self fib:(num-2)).

Uploaded Image: squeakcoweb.GIF

Links to this Page