Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resolving circular depenency

I have two class projects in a Visual Studio solution. Due to the nature of th project both projects reference each other because they need each other's services (think of the "I scratch your back, you scratch mine" phrase).

Visual Studio (2010) won't let me add a reference to project b from project a, because project a already references project b.

What strategies are there to resolve this circular dependency?

Thanks

like image 207
GurdeepS Avatar asked Dec 28 '10 18:12

GurdeepS


2 Answers

There are two typical approaches you can use:

1) Combine both projects into a single project.

alt text

2) Find the common parts of the two projects and factor them out into a separate third project.

alt text

like image 93
Mark Byers Avatar answered Oct 24 '22 20:10

Mark Byers


Refactor the independent services (those not dependent on the other projects) to a third class library and have both projects reference this third one.

On the other hand, if the two projects are so tightly coupled, then you should also considering combining them into a single project.

like image 38
Babak Naffas Avatar answered Oct 24 '22 21:10

Babak Naffas