Types versus classes

  • types -- type checking predicates
  • classes -- templates for object creation

Type specification

  • syntactically -- signature
  • (under)


  • semantically -- behavior
  • (right)


  • pragmatically -- implementation
  • (over)



slide: Types and classes


Modifications

  • types -(predicate constraints)-> subtypes
  • classes -(template modification)-> subclasses

Varieties of (compatible) modifications

  • behaviorally -- algebraic, axiomatic
  • (type)


  • signature -- type checking
  • (signature)


  • name -- method search algorithm
  • (classes)



slide: Type modifications


Signature compatible modifications

  • behavior is approximated by signature

Semantics preserving extensions

  • horizontal -- Person = Citizen + { age : 0..120 }
  • vertical -- Retiree = Person + { age : 65..120 }

Principle of substitutability

  • an instance of a subtype can always be used in any context in which an instance of a supertype can be used

  
subsets are not subtypes
Retiree \not<_{subtype} Person

Read-only substitutability

  • subset subtypes, isomorphically embedded subtypes

slide: The principle of substitutability


Name compatible modifications


  procedure search(name, module)
  if name = action then do action
  elsif inherited = nil
  	       then undefined
  else search(name, inherited)
  

slide: The inheritance search algorithm