University of Virginia, Department of Computer Science
CS201J: Engineering Software, Fall 2003

Notes: Thursday 16 October 2003
Schedule

There will be no sections tomorrow. Work on Exam 1.

Substitution Principle

B is a subtype of A means wherever an object of type A isexpected, we can use an object of type B instead.

For a function f (A), if f satisfies its specification when passed an object whose actual type is type A, f also satisfies its specification when passed an object whose actual type is B.

Signature Rule

Java's rule is stricter (novariant) — subtype signatures must match supertype signatures (except the subtype may throw fewer exceptions).

Methods Rule

Properties Rule
class A {
   public RA m (PA p) ;
}
class B extends A {
   public RB m (PB a);
}
               Substitution Principle 
Parameters     PB >= PA	              
Preconditions  pre_A implies pre_B    

Result         RB <= RA               
Postconditions post_B implies post_A  

Subtyping Example

   MysteryType1 mt1;
   MysteryType2 mt2;
   MysteryType3 mt3;
   ... (anything could be here)
   mt1 = mt2.m (mt3);
If the Java compiler is happy with this code, which of these are guaranteed to be true:
  1. The apparent type of mt2 is MysteryType2
  2. At the last statement, the actual type of mt2 is MysteryType2
  3. MysteryType2 has a method named m
  4. The MysteryType2.m method takes a parameter of type MysteryType3
  5. The MysteryType2.m method returns a subtype of MysteryType1
  6. After the last statement, the actual type of mt1 is MysteryType1

Java and C++ make you think that the new ideas are like the old ones.
Java is the most distressing thing to hit computing since MS-DOS.

Alan Kay

Don't worry about what anybody else is going to do. The best way to predict the future is to invent it.
Really smart people with reasonable funding can do just about anything that doesn't violate too many of Newton's Laws!

Alan Kay

And they showed me really three things. But I was so blinded by the first one I didn't even really see the other two. One of the things they showed me was object oriented programming they showed me that but I didn't even see that. The other one they showed me was a networked computer system...they had over a hundred Alto computers all networked using email etc., etc., I didn't even see that. I was so blinded by the first thing they showed me which was the graphical user interface. I thought it was the best thing I'd ever seen in my life. Now remember it was very flawed, what we saw was incomplete, they'd done a bunch of things wrong. But we didn't know that at the time but still though they had the germ of the idea was there and they'd done it very well and within you know ten minutes it was obvious to me that all computers would work like this some day.
Steve Jobs (on seeing a Smalltalk demo on his 1979 visit to Xerox PARC)


CS201J University of Virginia
Department of Computer Science
CS 201J: Engineering Software
Sponsored by the
National Science Foundation
cs201j-staff@cs.virginia.edu