Exercises for SASP 2008, week 1
Overall there are three exercises for this week, two of which must be handed in to firstname.lastname@example.org as a file out.
- Download, install, and get up and running with squeak.
- Implement a streaming operator as demo'ed at class.
- Implement a new style of subclasses which generates accessors for their instance variables
The following two exercises are hand-ins. Send the code as zip attachment, and explanatory text in the body of the email.
Exercise 2 (hand in by email, send a zipped file out to email@example.com)
The class in the file-in contains a single operator, which can filter a
stream or a collection. Your task is to program a similar class, but it
should not filter. Instead, its lambda expression should produce a new
object which becomes the element in the resulting stream. In SQL/Linq
terms this class would be named "Select", whereas it is called
"Collect" in Smalltalk.
(you might be tempted to refactor the two classes to have a shared super class, but leave that for later).
Exercise 3. (hand in by email, send a zipped file out to firstname.lastname@example.org)
The idea here is to create a new class which overrides the subclass
creation method. It will override it so that getters and setters are
generated as part of the subclass creation. We will keep it fairly
simple, that is, we will overwrite any existing accessor methods, and
we will assume this functionality can be defined in a fixed super
class. The latter design decision is hard to justify in a language with
You need to write most of the code in the meta class part of the class.
The magic method you will need is the method 'compile:classified:'.
Look it up in the method finder.