Re: When and where to use Visitor Pattern?



>>There doesn't seem to be a fundumental difference here.

>There is a huge difference in the execution timeline. There is also a

>big difference in the dependency structure.

There does seem to be a difference in execution time and dependendency.

The visitor (to me) exhibits the more coupling of the options, because
it forces any usage to be coupled to all visititable types, while "if
(instanceof(xyz))" only depends on those explicitly stated......this
may or may not be necessary....in general the safest way is to assume
that making a decision based on the type/interface of a object is
intrinsically linked to all possibilities....visitor enforces
this.....the "if (instanceof(xyz))"....doesn't.

I prefer the safety and the coupling, because I think it is safer to
assume this logic is coupled, than isn't.

To me the omision of a dependency that does exist is as bad (if not
worse) that the inclusion of one that doesn't. i.e. if coupling is
inherent it should exist in the code.

.



Relevant Pages

  • Re: When and where to use Visitor Pattern?
    ... >along with all the context derivatives. ... You have removed the dependency yes.....but you have changed the ... >On the other hand, if you use an if/else chain of instanceof, then the ... the coupling and the recompilation....(I'm assuming we ...
    (comp.object)
  • Re: Opinions on the Law Of Demeter
    ... Now the Contact class has a dependency to know that it's ... Increasing coupling and complexity (which is arguably where LoD-driven ... I want to see some code, not ramblings, Universe. ...
    (comp.object)