V
V
VicTHOR2020-10-09 10:33:07
Design patterns
VicTHOR, 2020-10-09 10:33:07

Why do you need a visitor, if you can without him?

Actually, why do you need the opportunity to do client.accept(visitor)when you can do it visitor.visit(client)?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2020-10-09
@VicTHOR

Because in strongly typed languages, you would first have to cast to a specific type in order to call the visitor's method. Actually, for the sake of solving this problem, the template was invented. This is also known as "double dispatching".
Can you be more specific?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question