Skip to content
Advertisement

Tag: visitor-pattern

Java visitor pattern instead of instanceof switch

In this question it is said I can use visitor pattern instead of a bunch of instanceofs. Jmg said “If you are not free to change A, B, and C, you could apply the visitor pattern to achieve the same.” As far as I understand I still have to make A, B and C support visitor (have an accept() method,

Advertisement