Tuesday 15 January 2013

Where should interfaces and other dependencies go in C#? -


By other dependence, I mean intangible class and something else.

I have a project that requires a fixed interface , IInput for a dll . This interface is also required for a test project, so I put this interface in my main project, which in turn has a different exe assembly.

That's because the main project at the end will need to use this interface when I wire everything together. Now the problem was that when I tried to add DLL to a reference in the main project with reference to the main project, I got a circular dependence.

I have never had this problem, do not I know the best way to combat it? One temporarily I was taken to different DLL interface, but very soon I will need it in its main project so that I can return back to square one.

Edit:

I should mention the design, so here goes.

  Menu menu test runner  

In the menu is INPT which is actually a unit adapter for a third party library for permission of unit testing.

Therefore the menu needs this for input, but such a runner runner (exe) will need input, so I'll need IInput again.

Because there is no relation to the interface test project or main project, just move it to a separate assembly , And refer to this assembly as both examinations and main.

  MySolution | - & gt; Interface Dll | - & gt; MainProject.exe (Reference Interfaces.dll) | - & gt; TestProject.exe (Reference Interface.DLL)  

No comments:

Post a Comment