






Hotspots: Admin Pages | Turn-in Site |
Current Links: Case Final Project Summer 2007
Joseph Goodfellow
About me
- CS major specializing in networking and databases
- Work full time as a T-Mobile Sales Representative
- gte411f (AT) prism.gatech.edu
- General useful Squeak stuff. This page is useful because it provides coding examples to obtain certain values and properties that could be useful. This is very helpful for someone not familiar with squeak. This page contains tips for acquiring inheritance information, instance information, using the debugger and inspector, and some miscellaneous examples with collections and retrieving ASCII values.
- Mini Java-to-Squeak Tutorial. This is an awesome squeak tutorial for those not so familiar with squeak, but familiar with JAVA. You will find comparison examples of JAVA to Squeak code for assignment, comments, strings, string operations, logical operators, statement termination, conditionals, and loops.
- Proper CRC Card Creation. This page will be very useful for finishing milestones one and two, since it provides examples of how to make proper CRC cards. It provides an example of a CRC card done wrong as well as the same card done right and points out the difference in the information listed by a CRC card and a UML diagram..
- Team ASDF Case Page. This page has an excellent "how do I..." page that provides some excellent tutorials for Squeak. A large portion of the page focuses on the use of the Comanche server. The page also contains useful information on how to perform file I/O in squeak, and also includes information on how to make use of class names and some basic information on saving in Squeak. This page also provides some information on using "step" and making and using previews.
The following Smalltalk statements are written in a Squeak Workspace. In order from top to bottom, you execute each statement with Alt-p to print its result. Next to each statement, write the result.
1 + 2 * 3 - 4 factorial -15
a := #(1 2 3 4 5) #(1 2 3 4 5)
a select: [:i | i odd] #(1 3 5)
b := a #(1 2 3 4 5)
a := a reversed #(5 4 3 2 1)
b collect: [:i | i * i] #(1 4 9 16 25)
a perform: #at: withArguments: #(4) 2
A palindrome is a word or phrase that has the property of reading the same in either direction (ignoring punctuation, spaces, and capitalization). So, for instance, a palindrome newspaper headline when the Red Sox finally won the World Series might have read, "Boston did not sob" Write the Smalltalk method to determine whether a String is a palindrome. This code should not just function properly, but use good object-oriented style. To that end, be sure to identify the class in which the method is implemented and whether it is an instance or a class method. (Hint: Characters respond to the message isAlphabetic.)
This method should be implemented in the String class as an instance method.
isPalindrome
"compare self without spaces and punction in all lowercase with
self (in same state) but reversed, and return the boolean result"
^( ((self asLowercase) onlyLetters) sameAs: (((self asLowercase) onlyLetters) reversed) )
- Message Passing (1 point)
Smalltalk is built on a few uniform design principles. One of these is that computation happens through message passing: An object gets sent a message (perhaps with some arguments) and returns an object. Even traditional control structures (while loops, for loops, if/then/else) are implemented through message passing. For each of the control structures below, translate the Java code into Smalltalk. For each part, indicate what is the object, what is the message, and what are the arguments.
while loop
while (aBooleanTest)
{
// do stuff
}
In Squeak:
[aBooleanTest] whileTrue: ["do stuff"].
object = "[aBooleanTest]".
message = "whileTrue:".
arguments = "["do stuff"]".
(NOTE: the argument is also an object)
for loop
for (i = 1; i <= 10; i++)
{
// do stuff
}
In Squeak:
1 to: 10 do: [:i | "do stuff"].
There are multiple objects, messages, and arguments here.
objects = "1" and the return value of "1 to: 10".
messages = "to:" and "do:".
arguments = "10" and "[:i | "do stuff"]".
(NOTE: the arguments are also objects)
if/then/else
if (aBooleanTest)
{ // do stuff
}
else
{ // do stuff
}
In Squeak:
[aBooleanTest] ifTrue: ["do stuff"] ifFalse: ["do stuff"].
object = "[aBooleanTest]".
message = "ifTrue:" and "ifFalse:".
arguments = both "["do stuff"]" blocks.
(NOTE: the arguments are also objects)
Write a Squeak method that contracts a string to a certain size by inserting an ellipsis (...) in the middle of the string. So, contracting ‘I am the Walrus’ to a size of 11 equals ‘I am...lrus’ (4 beginning characters + 3 periods + 4 ending characters = 11 total characters). Your method should deal with special cases, such as when the string is short enough that it doesn’t need to be contracted. This code should not just function properly, but use good object-oriented style. To that end, be sure to identify the class in which the method is implemented and whether it is an instance or a class method.
This class should be implemented in the String class as an instance method.
contractToSize: size
"contracts self with an ellipsis to 'size' length if greater than 'size'"
(self size) <= size
ifTrue: [
^ self. "String's contractTo: already does this, but added to indicate method behavior"
] ifFalse: [
^ (self contractTo: size).
].
- Garbage Collection (1 point)
Reference counting was one of the first implementations of garbage collection. Ultimately, it proved problematic. Why?
It was possible for a circular reference to exist, which equated to two objects pointing to each other but nothing else which will never be garbage collected.
Name two advantages and one disadvantage to using garbage collection.
- Two advantages are, easing the programmers burden of memory management and also, an increase in security and safety (no worries of memory violations or run time core dumps).
- One disadvantage is performance (not as big of an issue anymore, now the biggest problem is control).
- Extreme Programming (1 point)
Describe in detail how pair programming is done.
- Two people in front of a single computer at the same time.
- Sit side-by-side and slide the mouse and keyboard back and forth.
- The driver types and thinks tactically about the method being created.
- The navigator thinks strategically about how the method fits into the class.
What is the role of pair programming in extreme programming?
- Pair programming increases software quality without impacting the time to deliver a method.
- By trading partners frequently everyone knows about the project as a whole, and the team can thus recover from somebody leaving the team.
What is the role of unit testing in extreme programming?
- All code must have Unit tests and when bugs are found unit tests must be written for those bugs.
- Unit tests should be written before the respective methods they test, to allow the programmer to know when the method is complete (by passing the unit test for that method.)
- Also, completion of unit tests and acceptance tests can be used as a benchmark of the project velocity and anticipated completion time.
Links to this Page
- Summer 2006 Who's Who last edited on 3 September 2007 at 8:57 pm by adsl-215-134-227.aep.bellsouth.net
- Squeak U last edited on 1 August 2006 at 10:26 pm by veracruz-win.cc.gatech.edu