Double Dispatch for Two-Tiered Type Checking
Adair Dingle, Seattle University
To streamline the integeration of design and OOP, we provide an intricate design example that illustrates the streamlined use of a common pattern (Double Dispatch aka Visitor) while reinforcing the processes of type-checking and polymorphism. We break down the presentation of the problem and the development of a solution in multiple steps. Our example is given in C++ via operator overloading but the same conceptual emphases could be achieved in other languages using function calls. Our approach has been effectively used in both OOP and design patterns courses, yielding the benefits of increased awareness of good design techniques as well as improved comprehension of type-checking, inheritance, function calls, polymorphism, extensibility and maintainability.