Lecture Notes for Advanced Programming II

18 January 2001 - Abstraction, Polymorphism, and Dynamic Binding


  1. abstraction - managing details

    1. a detail - any particular fact, claim, observation, ... about a thing

    2. why manage details - humans can't handle (remember, use) many details at the same time; the 7 +/- 2 short-term memory problem

    3. humans ignore the myriad of details by ignoring them - focusing on the wrong details, not focusing on the right ones

    4. abstraction is a technique for focusing on the right details

    5. selectively present important details by suppressing unimportant ones - suppressing is not ignoring

    6. levels of details, layers of abstractions

      1. if detail a uses detail b, then a is at a higher level than b

      2. if the details in the abstraction layer a are at a higher level than the details in abstraction layer b, then a is a higher level of abstraction than b

    7. when is a level of detail appropriate for a layer of abstraction

      1. relevance - so what

      2. when a detail can vary widely and not change the abstraction, its irrelevant and belongs at a lower level

  2. polymorphism - abstracting away types

    1. types may not be important at some level of detail - how many elements in a list; a stack implementation

    2. polymorphism suppresses type details - polymorphic language features; polymorphic data types, polymorphic functions, polymorphic variables

    3. polymorphism is valuable - abstraction and re-use

    4. strong typing is not polymorphic - type is always a detail; pascal

    5. dynamic typing can be polymorphic - java

    6. weak or broken typing can be polymorphic - c

    7. polymorphism occurs in many forms, but they all abstract types

  3. dynamic binding - making inheritance really polymorphic

    1. inheritance specifies a relation among classes - superclass-subclass, parent-child

    2. many interpretations of the inheritance relation

    3. is-a relation - class s is-a class q

    4. class s is-a class f and class c is-a class f imply, at some level, no difference between f and c - polymorphism

    5. member functions can break polymorphism

      1. parent classes can require child classes implement functions

      2. which function gets called - usually the wrong one; the topmost one

    6. virtual member functions repair polymorphism - call the bottom-most one


This page last modified on 18 January 2001.