Introduction to Object Oriented Programming, 3rd Ed

Timothy A. Budd

Chapter 16

Overriding

Outline

  1. Roadmap
  2. Difference from Overloading
  3. Overriding Comparison in Smalltalk
    1. Subclasses of Magnitude in Little Smalltalk
    2. Overridden Relationals
  4. Notating Overriding
  5. Replacement and Refinement
    1. Reasons to use Replacement
      1. Overriding a Default Method
      2. Overriding for Optimization
        1. More Efficient Versions in class True
      3. Downside of Replacement
    2. Refinement in Beta
      1. Example, Print Anchors
      2. Making Child Classes
    3. Simulating Refinement with Replacement
    4. Constructors use Refinement
  6. Overridng versus Shadowing
    1. Shadowing of Instance Variables in Java
    2. Shadowing Methods
    3. Overriding, Shadowing and Redefinition
  7. Covariance and Contravariance
    1. Contravariant Return Types
    2. A Safe Variance Change
  8. Chapter Summary

Other Material

Intro OOP, Chapter 16, Outline