Lecture 19 continuted: More Visitors

Ambient temperature: 74.4oF

Concepts

  1. Dr. Wong demonstrates the visitor design pattern:
    1. The HostA-HostB-HostC visitor pattern from last class’ lecture.
    2. Linked Lists with counting, summation, copying, and mapped addition.
  2. The visitor pattern is an example of “double dispatch:” First the visitor object is dispatched to a host object, then a particular method is dispatched from the host to the visitor object.
  3. Accumulators: Unfortunately, still forming a succinct summary; got distracted by loop invariants :(

Quotes

  1. “What is a duck? A duck is a thing that acts like a duck.” – Dr. Wong
  2. “Ducktyping is about ‘can we use it as a duck?’ What I’m talking about is ‘how do we define a duck?'” – Dr. Wong

Resources

  1. Lecture 19 webpage on visitors: http://www.clear.rice.edu/comp310/f12/lectures/lec19
  2. Simple visitor demo: http://www.clear.rice.edu/comp310/f12/demos/VisitorDemo/
  3. Linked list visitor demo: http://www.clear.rice.edu/comp310/f12/demos/ListFW/
  4. Double dispatch on Wikipedia: http://en.wikipedia.org/wiki/Double_dispatch