Difference betwen Visitor pattern & Double Dispatch

前端 未结 5 1666
逝去的感伤
逝去的感伤 2020-11-30 00:05

I am reading about visitor pattern, and it appears the same like Double Dispatch. Is there any difference between the two. Do the two terms means the same thing.

re

5条回答
  •  Happy的楠姐
    2020-11-30 00:11

    Visitor pattern is one solution which implements the behaviour of double dispatch. There can be several other solutions as well. The term double dispatch itself doesn't give any idea of solution, in fact it is a problem whose solution is provided by visitor pattern.

    In C# (4.0), one could use dynamic keyword to implement double dispatch, in which case visitor pattern is not required. Here is my solution to double-dispatch problem using dynamic keyword:

    • Advantages and Disadvantages of C# 4.0 'dynamic' keyword?

提交回复
热议问题