1

I have an ecomm application in Project#1.

I have a payment gateway implementation in Project#2 that references Project#1. It references interfaces so that the gateway is implemented to a contract.

Now I need to actually use the implementation from Project#2 in Project#1.

There is a circular dependency so it isnt' working as it is.

What shall I do? Should I break the interfaces into their own project? That seems like the easiest approach.

The point is that if I need to create another implementation of a gateway, it can easily be incorporated into Project#1.

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
mrblah
  • 99,669
  • 140
  • 310
  • 420
  • Didn't you just ask this question in a different way here -> http://stackoverflow.com/questions/2052579/circular-dependancies/2052632#2052632 – Craig Wilson Jan 12 '10 at 21:49

4 Answers4

1

Putting interfaces in a separate library is often a good idea. It also ensures that you can vary and deploy concrete implementations independently of each other.

As a general rule of thumb, when I design, I start by putting the interfaces together with their consumers, and I then move them to a separate library if the need arises.

As far as I understand your description, you have consumers in each library, so moving them sounds like the correct approach.

If you find that these interfaces are sufficiently unrelated, you may even want to consider putting them in two different libraries.

Mark Seemann
  • 225,310
  • 48
  • 427
  • 736
0

Yes. You should put the interfaces that the plugins should implement (along with any potential common helper code) in a separate assembly.

Nick
  • 5,875
  • 1
  • 27
  • 38
0

Yes, break your interfaces into another project and reference that project from both. This way, both are dependent upon an abstraction.

Craig Wilson
  • 12,174
  • 3
  • 41
  • 45
0

This is a dupe of your other question, but it at least has more detail.

If Project 2 is a plugin to Project 1, then Project 1 should not have any dependencies on Project 2, under any circumstances. Period.

Load Project 2's assembly into Project 1 via reflection/MEF/etc.

kyoryu
  • 12,848
  • 2
  • 29
  • 33