By trisa
via jroller.com
Submitted: Aug 06 2008 / 21:28
I lately had to implement instance comparison where the object type determines a part of the result. The classic approach would have been to implement comareTo() with different checks on the object type using instanceof. I usually like perfect OO style and that's why I thought about using the double dispatch pattern, avoid those instanceof checks and end up in a far more elegant implementation.
Add your comment