I am struggling with avoiding cyclic dependencies. I know I need to hide the implementation with interfaces, but how do I handle a situation with two assemblies, where each either needs to instantiate classes from the other or call a static method from there?
Edit:
I understand this can be fixed by using just a single assembly. We have more than one for the following reason:
- our "system" consists of several components. A customer can have just one component, or more - so what we did is we created different assemblies for different components. It kind of makes sense - why would you deploy things that you do not need - is it not a wasting of memory?
- things that were common to more components, mostly helper classes, went to another assembly - again not all components need all helper classes, so there are more assemblies
- however, these two applications can talk to each other - the system for doctors sends requests to the system for nurses, requests are going back, etc. - and here's where the actual problem is
Having the two components talking to each other is really just one of the situations we've had a cyclic dependency conflicts before. It happens now and then and when it happens we need to figure out how to solve it - move some classes around - and sometimes we need to add a new assembly.
Now we have like 8-10 assemblies, and it looks like the more you have the faster they get added :) - for example, we added a general purpose feature that uses custom attributes - so we added another assembly just for the attribute - just in case we do not get in conflict in future
Is this the way to go? I am really feeling we are doing something fundamentally wrong :)
I really appreciate your input.