Assignments
The purpose of the homeworks is to prepare you for the class project. It
also forces you to keep up with the course, and it lets me assume that
you've read the book, so I won't have to lecture on the material. This
is a graduate course, after all, so I assume that you'll learn the material
from the book on your own, and I can concentrate on the material that isn't
in the book, and making sure you see the big picture.
Homeworks will come fast and furious at first, then you'll move on to
work in a project. Feel free to talk with other people about the homeworks.
However, there will be tests and quizes based on the material in the homeworks,
so if you don't do the work, you will do poorly. In fact, it is good to
do your homework with a partner. You learn more with a partner, and you
might spend less time. If you do a homework with someone else, just submit
one solution and put both your names on it. Make
sure that you are doing equal amounts of work. If your partner is doing
most of the work, get another partner or you won't learn as much.
Send in all homeworks to cs497@chip.cs.uiuc.edu by 10:30 a.m. of the
day it is due. Do NOT use attachments. Include all code by pasting it into
your message. If you use attachments then we will end up with hundreds
of little files, mostly with the same name. This makes it hard to tell
which file is yours. Make the subject of your message by "homework 1",
"homework 2", and so on. This will help us keep them separate if you are
ahead of schedule. You can go as fast as you want, but we
probably will hand back your homeworks along with everybody else's.
Many students have asked questions about the homeworks and have had
them answered on the swiki.
Take a look at these questions before you start a homework, and feel free
to ask more questions. The homeworks change a little each semester, and
we try to edit the questions to keep up with the changes, but sometimes
we make mistakes.
Again these schedules that I have mentioned here are tentative. Please
look out for any changes in them.
-
hw1 - Aug 27 - Do all exercises in the first 6 chapters
of Hopkins and Horan. These chapters and exercises are all easy, so this
is sort of a warm up for the later homeworks. Even so, this is a lot of
material, and I estimate it will take you 5-10 hours to work through it
all. Note that none of the exercises require you to send us anything until
chapter 5. Send us (by e-mail) the results of exercises 5.14, 6.3, the
files you created as exercise 6.12 and 6.13. What is the result of
evaluating (using "print it") the expression "100 factorial"?
Also, go to the
class wiki and make an
entry for yourself under the "list of people". Introduce yourself, explain
why you want to take this class, and leave your e-mail address.
-
hw2 - Sep 1 - Read chapters 7-9 of Hopkins and Horan.
This is 35 pages. Do the exercises in chapter 7, sending us the results
of 7.6, 7.8, and 7.9.
Pay close attention to the hint of 7.9. The problem
is that some methods don't return what you expect. In particular, "x at:
3 put: 'third'" will not return x. However, "x at: 3 put: 'third'; yourself"
will return x.
Do the exercises in chapter 8, sending us the results
of 8.3 and 8.4. 8.5 is optional. Do the exercises in chapter 9 too, but
don't send us anything.
Get the source code for the Payroll
example that we did in class. Check the Employee class and the three subclasses
of EmployeeTransaction to see whether they are using the proper pattern
for initializing objects. In other words, whether there is a "complete
creation method" as a class method and an "instance initialization method"
as an instance method. If not, fix them, and report what you changed.
Write a script that simulates the following. Write
it in a workspace. Keep adding to it little by little. Read the code to
figure out the exact syntax for anything you don't know how to do. Note
that the class method "test" of PayrollSystem is a lot like this. Send
in the script for the following:
John Doe was hired May 1, 1999. His initial salary
was $20 an hour. He turned in his time-card on May 5 and had worked
40 hours. He worked 40 hours the week of May 12, too. He received a pay-check
on May 15. What was his take-home pay?
-
hw3 - Sep 3 - read chapter 10-13. It is very important
to learn to find things in the class library. These exercises will
help teach you that. They require looking around with the browser. So,
you need to learn to find the implementation of a method with a particular
name (use "find implementors"), the variables defined by a class, and so
on. Smalltalk has excellent tools for this, but you can't
use them until you learn them. Do the exercises in 10 and send the results
to us.
Explain the results of 11.1, 11.2. Do 11.5. Make
a method in Date that subtracts a number of days from an instance of
Date. What should it be called? What protocol should it be in? (Hint, find
the method that adds a number of days to a Date.) File out that method
and hand in the code. Do 12.4, 12.6, 12.7, 12.8, 12.11 (show us the code
for Foo), 13.3, 13.4, 13.5, 13.9, and 13.13. Where is Rectangle's implementation
of the "new" method? (This might be harder than you think!) Smalltalk
is ideal for experimentation. If you want to know whether something will
work, just try it!
-
hw4 - Sep 8 - read chapter 22 and 23 on debugging, do
the military
rank homework.
-
hw5 - Sep 10 - read chapters 14 and 15. Do exercise
15.2. A binary tree is a collection that is made up of a set of nodes.
Each node has two children and a value. The value
stored in a node is greater than or equal to the values of its right-most
child or any of its children. The value stored in a node is less than or
equal to the values of its left-most child or any of its children. The
trick is to note that each node is itself a binary tree, so you only need
to make one class, BinaryTree, which is also the class of your nodes. Make
your binary tree class a subclass of Collection, not Object, and
implement do:. Note that do: should evaluate the block only for the
values of the nodes, not the nodes themselves. The binary tree should then
be able to understand size, addAll:, and inject:into:. Test it to make
sure. It might be able to understand collect: and select:. If it doesn't,
explain why not. Do the collection
homework
The payroll system doesn't handle vacation. Class
Employee has a variable defined for it, and each time-card collects
the amount of vacation time that was taken that week, but the code for
processing time-cards doesn't do anything about vacation.
Change the payroll system to record the amount of
vacation time that has been taken and the vacation time that has accrued.
Assume that for every 50 hours of non-overtime that an employee works,
they get 2 hours of vacation time. You should not need to add any more
instance variables to any classes. You could do this by adding to accrued
vacation (hours worked / 25) - hours of vacation taken. Note that
this will lead to fractional hours of vacation accumulated. This
might be a problem if this were being written in COBOL, but it is OK for
Smalltalk.
To find where the work gets done, try single-stepping
through the posting of a time-card. Place a halt to start the debugger,
and then single-step from there. You'll have to figure out how to get the
hours of vacation taken and the hours worked. They are stored in the time-card.
-
hw6 - Sep 15 - Read chapters 16, 17, and 18. Do the
Money
exercise. Note that Money is really a double-dispatching exercise.
-
hw7 - Sep 17 - Do the streams
homework.
-
hw8 - Sep 22 - read chapters 21, 24, and 27, Change
Employee to use ValueWithHistory
to store values that change over time. You won't use it to store the name
of the Employee or its set of transactions, but you can use it for just
about everything else. This will permit old transactions to work correctly
even if a salary change or something similar has occurred.
You will have to change the initialization method
to initialize the Employee properly. Then you'll have to change everyplace
you read the variable to use #at:, everyplace you assign to the variable
to use #starting:become:, and everyplace you increment the variable to
use #at:add:.
Define a method for Employee called salaryHistoryOn:
aStream. It prints a report on aStream that gives the dates of all salary
changes and what the new salary was. The report should look something like
January 15, 1975: $2.00 July
15, 1975: $2.10 January 15, 1976: $2.30 July 15, 1976: $2.50
Do NOT hand in the entire payroll example. Just hand
in your changes. We do not want to run your program, we want it to
be so clear that we can read the changes and tell that it is correct.
-
hw9 - Sep 24 - read chapters 19, 20, 28. Do 19.5, 19.6,
20.6, 20.9, 28.6, 28.8 and do the withholding
homework for the payroll system.
-
hw10 - Sep 29 - read chapters 29 and 30. Read the patterns
Strategy, Decorator, and Composite from the Design Patterns book. For each
pattern, describe a place where you have seen the pattern in the homeworks
or in the Smalltalk image. Do 30.8-30.13.
-
hw11 - Oct 1 - read chapters 31-33. Do 32.1-32.14 and
32.21. Read the patterns Observer and Template Method. For each pattern,
describe a place where you have seen the pattern.
- Learn the VisualWorks GUI builder. There is a
VisualWorks tutorial for VW2.5 that is available in pdf.
But since there isn't one for VW3.0, perhaps they think that sections
17-23 in the Advanced Developers Guide (look in your "doc" directory) should
be enough. Also, if you haven't found a class project, get one soon!
-
hw12 - Oct 8 - The last homework! Build a GUI for the
payroll
system. If I go too slowly through the GUI lectures, you can wait
til I'm done. Read Adaptor, Mediator and Interpreter. For each pattern,
describe how the VisualWorks GUI framework uses the pattern.
-
Oct 13 - You should have chosen your project by now. Make sure there is
a page on the class wiki that describes your project, and that you are
listed as one of the members of that project.
-
Oct 27 - First demo. You should be ready to give a 15 minute demo of what
you have done so far and to describe the problem you are solving and your
current design. Also, you should have some sort of schedule for the rest
of the semester that describes the tasks you have left, how long you think
they will take, and who will do them. You are not required to follow this
schedule, but it is good to think about it to make sure that you aren't
trying to do too much.
-
Nov 17 - Second demo. You should be ready to give a 15 minute demo of what
you have done so far and to describe the problem you are solving and your
current design.
-
Dec 10 - Public demo. Some of you will give demos in class. Let me know
by Wednesday (Dec. 8) whether your group will give a demo.
Final presentation of projects will be the week of finals through
December 21.