[an error occurred while processing this directive]
cs205 Friday 22 September 2006
Upcoming Schedule
- Now: midterm due
- this week: read chapter 13
- Friday, 6 October: problem set 4. Problem set
4 will be accepted without penalty until Tuesday, October 10. If you
don't turn it in class on October 6, you must turn in a paper copy under
my office door before 5:00pm on Tuesday, October 10. Email-only
submissions will not be accepted.
- Monday, 9 October: No class (reading day)
Array Subtyping
public class SubType {
static public void setLast (Object [] arg, Object val) {
// REQUIRES: arg has at least one elements
// MODIFIES: this
// EFFECTS: Sets the last element of arg to val.
arg[arg.length - 1] = val;
}
public static void main(String[] args) {
String [] sarray = new String [2];
setLast (sarray, new String ("Hello"));
System.out.println ("val: " + sarray[1]);
setLast (sarray, new Object ());
System.out.println ("val: " + sarray[1]);
}
}
If S ≤ T, should S[] ≤ T[]?
Design
What does it mean for a design to be good?
What should a design document document?
Modular Dependency Diagrams
- A → B means A depends on the specification of (uses) B
- A dashed arrow B means A depends on the existence of (weakly uses) B
If the specification of M changes, then all modules that depend on M
need to be reconsidered.
Is this a good design?
How is a taste in this beautiful art to be formed in our countrymen,
unless we avail ourselves of every occasion when public buildings are to
be erected, of presenting to them models for their study and
imitation?...You see, I am an enthusiast on the subject of the arts. But
it is an enthusiasm of which I am not ashamed, as its object is to
improve the taste of my countrymen, to increase their reputation, to
reconcile them to the rest of the world, and procure them its praise.
Thomas Jefferson (letter to James Madison, 1785)