Plugin design, having circular dependency issues

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.

Answers


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.


Need Your Help

Cannot insert moment - Google Plus API

ios api post google-api google-plus

I have an iOS Application which authenticates with the Google Plus API via OAuth 2.0. The issue I have is that I can't POST my moment even though I have followed the Google Documentation exactly. H...

How do I change my XML to have hibernate to define the DataSource

java spring hibernate spring-mvc

can someone please show me how to change my XML to have hibernate to define the DataSource. I would like to see a good sample of it. Below is my xml file. can someone post what it would look like...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.