CS 448 Lecture - Java abstraction

Topics for today:
  1. Reading
    1. C9, C10: The "replicator"; panspermia. Time scales. Aside; things are not always simple, e.g. sweat glands. Culture as adaptive/evolving; memes (ideas are like viruses)
    2. Samuel - design for minimax code
  2. Lab due date extended *again*!?! Yes, 'til Tues... but with bonus for already demo'd
  3. Interface in Java
    1. An interface is just a list of signatures of methods a class must, uh, implement in order to implement that interface
    2. Helps write generic code
      1. Collections.sort(ArrayList<String>)
      2. Implementing Comparable with Strings inside a class
      3. Implementing Comparable with ints inside a class
    3. Facilitates team programming
      1. Example: robot cars. Agree on the Driveable interface, then one person can write the driver and the other can implement Driveable
      2. Allows decoupling
      3. Each side (of the interface) can develop/test independently
      4. Designing a Driveable interface
        • input devices - camera, sonar, GPS
        • output devices - brake, throttle (both boolean!), steering (can adjust by +left or +right)
    4. Addresses the lack of multiple inheritance in Java
    5. Parameter types may be interfaces!
  4. Abstract classes in Java
    1. Makes it possible to abstract commonalities from two (or more) classes.
    2. Like interface, makes it possible to require certain methods to be implemented. Each signature is preceded by abstract; each must be overridden in subclasses (which are not themselves abstract).
    3. Methods may be implemented in the abstract class; if they are not overridden in a subclass when sent to the subclass object the superclass method is executed.
    4. Can declare variables in abstract classes
    5. Cannot instantiate!
    6. Classes may only extend one other class
    7. Parameter types may be abstract