Skip to main content
7 events
when toggle format what by license comment
Jan 6, 2018 at 2:12 vote accept donquixote
Jul 9, 2014 at 15:22 comment added donquixote I am not really convinced that what we are doing here matches the definition of a Visitor pattern. Also see stackoverflow.com/questions/350404/…
Jul 9, 2014 at 3:41 comment added paisanco @donquixote yes in effect your Vistor classes act as proxies between the Car and the Driver and Mechanic. It's isolating the pain to the Visitors. The pain isolation would become more apparent if you had to iterate over many Cars.
Jul 9, 2014 at 3:38 comment added donquixote And it does introduce some clutter and code duplication, at least signature duplication. Similar to a Proxy class. Whenever I add a new method I now need to change two places. Any idea how to avoid that, or at least reduce the pain?
Jul 9, 2014 at 3:38 comment added paisanco @donquixote Yes, you were on the right track with approach #2, Visitor is an established way of doing this.
Jul 9, 2014 at 3:36 comment added donquixote So in essence the DriverVisitor is just a wrapper for the Car, as suggested in the second approach in the question? I think I can imagine the implementation, but still need to read the pattern definitions ..
Jul 9, 2014 at 3:32 history answered paisanco CC BY-SA 3.0