| ||
Student Originated Software 1997-1998
| ||
A Software Engineering Course at The Evergreen State College | ||
|
Object Oriented ProgrammingAbout Double DispatchingDouble dispatching is a useful technique for efficiently choosing an algorithmbased on the classes of one or more of the arguments of a message as well as the class of the receiver. For example, we might wish to evaluate the following expression:
among algorithms designed for Integers, Fractions, and Floats. The fastest way to do this is for it to simply send the argument of the message another message--as shown here:
<primitive: 1> ^aNumber sumFromInteger: self
what must be done to add itself to the integer. Note that the order of the numbers has changed, so that in methods such as Fraction>>quotientFromInteger:, it is the argument that is divided by the receiver, and not the receiver divided by the argument In the system as delivered, there are five operations that are subject
to
|