.NET - Can you over interface, and when shouldn't you interface

.net, interface

Solution

Interfaces describe a contract for behavior. If you need to address some set of objects according to a behavioral pattern, interfaces are useful, not so much if you're simply describing the structure of objects. I think you need to have a good reason to use them, such as using a factory that creates behaviorally related objects or establishing a behavioral contract for part of a library. Using interfaces aimlessly can make a library difficult to read / understand / maintain.

Problem

Is it possible to over interface? when designing an system now, I will start from interfaces and progressively write unit tests along with the interfaces until I have a pattern that works well.. I'll move onto writing some concrete classes and set the unit tests up against these.. Now I'm someone who loves interfaces, I will generally end up only ever passing/returning primatives or interfaces around when I control the code.. so far I've found this to be ideal, you can easily adapt and enhance a system generally without impacting the dependent systems. I obviously don't need to sell the reasons for using interfaces, but im wondering if its overboard to interface everything, ps. I'm not talking about blank interfaces as in something crazy like: ``` interface IStringCollection : ICollection<string> { } ``` I'm talking more something like: ``` interface ISomethingProvider { ISomething Provide(ISomethingOptions options); } ``` Is this really over the top? my reasoning is that any type could gain from interfacing at some point.. and the only real problem I've had is that I've had to learn what I think is a better way to design classes, as you don't have daft interactions and 'hacks' going on. Would love your feedback about if this is a timebomb, and when you decide to interface vs not.. ps- this isn't really so much about how to write interfaces.

Original source