mardi 24 août 2021

Is it possible for a visitor to operate over multiple projects?

I'm trying to add a visitor to an existing library. The visitor must be able to visit some classes from separate projects.

Let's say my solution have the following projects: ProjectA, ProjectB and they contain 1 class each respectively: ClassA, ClassB. Since the visitor is only an implementation of a class member outside of the class, I think its dependency won't allow it to be placed at another project. So if I want to create a visitor which can visit both ClassA and ClassB objects, I can't use a simple visitor.

Is this assessment correct?

I was thinking about a couple of solutions to overcome this.

  1. Move one the classes to the other projectand implement visitor there (this isnot a feasible solution).
  2. Add an extra indirection. Create a class for the visitor implementation for each project. And create a "head visitor" which would use these implementation objects.

Am I missing something? Is there a better way to do this?

Aucun commentaire:

Enregistrer un commentaire