Reputation: 1388
I have an Adaptor with finds Sources and returns it. But I need a keep a reference of the Adaptor with all its sources. But this Design will create a circular dependency.
IAdaptor need a function with returns a list of ISource, and each ISource needs to keep a reference of it own Adaptor.
ISource is kept in a Project 1 and IAdaptor in Project 2
How do I accomplish this, without creating a circular dependency with each other?
Upvotes: 0
Views: 198
Reputation: 1388
I would recommend you to take a look at what functionalities ISource really need from IAdaptor: what methods on IAdaptor are called from ISource implementation, and are those methods really tied with IAdaptor.
In some situations, it may be appropriate to move those functionalities out of IAdaptor as a separate and more generic interface (I'll call it ISourceDependency), and put it in the same assembly of ISource. ISource would depend on ISourceDependency instead of IAdaptor, and thus the circular dependency is removed. Then you just needs to let the adaptors implement ISourceDependency in addition to IAdaptor.
If you find the methods on ISourceDependency really tied with the logic of IAdapter, then it'd be better just to put IAdapter in the same assembly as ISource.
Upvotes: 1