Visitor Pattern Usage

Gammerz 4 years ago 0

The benefit of the Visitor pattern is unclear to me

In the Real World Example, instead of calling the accept method on the Company instance, why not call the Visit Company public method on the SalaryReport, passing the Company instance? Then the accept methods and Entity interface become redundant. I realise this is the reverse way of looking at the problem, calling a method on the SalaryReport rather than the Company, but this Visitor example seems to make a simple solution more complex and is superfluous.