I am just reading Agile Principles, Patterns and Practices in C# by R. Martin and M. Martin and they suggest in their book, to keep all your interfaces in a separate project, eg. Interfaces.
As an example, if I have a Gui project, that contains all my custom Gui classes, I will keep their interfaces in the Interfaces project. Specifically I had a CustomButton class in Gui, I would keep the ICustomButton interface in Interfaces.
The advantage is, that any class that needs an ICustomButton does not need a reference to Gui itself, but only to the much lighter weight Interfaces project.
Also, should a class in the Gui project change and thus cause it to be rebuilt, only the projects directly referring to the CustomButton would need recompilation, whereas the ones referring to the ICustomButton may remain untouched.
I understand that concept, but see a problem:
Lets say I have this interface:
public interface ICustomButton
{
void Animate(AnimatorStrategy strategy);
}
As you can see, it refers to AnimatorStrategy, which is a concrete class and therefore would sit in a different project, lets call it Animation. Now the interface project needs to refer to Animation. On the other hand, if Animation uses an interface defined in Interfaces, it needs to refer to it.
Cyclic dependency - "Here we come".
The only solution for this problem, that I see, is, that all methods defined in the interfaces take inputs that are themselves interfaces. Trying to implement this, will most likely have a domino effect though and quickly require an interface to be implemented even for the most basic classes.
I don't know if I would like to deal with this overhead in development.
Any suggestions?