C# – Where to Define Interfaces in a Multi-Tier Project?

cinterfacesobject-oriented

I have a multi tiered project made up of three sub projects, i.e. Data access project, Business Logic project and Presentation project, where should interfaces be defined?
I'm guessing that there should be interfaces defined in both the DAL and BLL..
In the context of testing the Business Logic Layer by using "test" data based on the interface it seems that maybe there should be a separate project with just the interfaces?

Any best practices or idea on how this should be arranged?

Best Answer

One good approach to this is to use the stairway pattern:

enter image description here

So the DAL lives in one project, its interfaces in another, the BLL in a third, its interfaces in a fourth and so on.

The idea being that when testing eg the business layer, you then just reference the DAL interfaces project, rather than dragging all of the real DAL and eg NHibernate into scope just to get at those interfaces.

As far as I know, this pattern is the creation of Gary McLean Hall in his book, "Adaptive Code via C#: Agile coding with design patterns and SOLID principles"