Multiple Dispatch in practice
bearophile
bearophileHUGS at lycos.com
Thu Oct 23 01:40:54 PDT 2008
Sergey Gromov:
> You overcomplicate.
> ...
> interface Vehicle {
> void collide(Vehicle v);
> void onCollision(Car c);
> void onCollision(Bike b);
> }
You oversemplificate :-) You have had to modify the original interface. I'll not use your version of the code. Multiple dispatch allows you to not modify the original interface, keeping changes more localized. If Car manages 5 collisions, while Bike 7, and they share just 3 collisions, your interface and classes become quite hairy...
Bye,
bearophile
More information about the Digitalmars-d
mailing list