[quote name='ChaosEngine' timestamp='1342995676' post='4962051']
Just to add that interfaces are generally easier to mock and hence unit test client code.
Care to elaborate on this? I don't see how they're really any easier to mock.
[/quote]
Sure. Mocking frameworks such as NMock, Rhino Mocks and Moq mostly work with interfaces. Some of them have some support for mocking abstract classes, but it's a lot easier to use interfaces (hence my comment).
IMO, both have their place. From the perspective of a consumer of a component/class/service, an interface makes the most sense. For an implementer of a service, if there is shared state or functionality, then an abstract class will, as you pointed out reduce DRY.
Or people extend that interface with another. More often than not, the source module then needs to do type checking/casting to see if some other interface happens to be on the returned type, violating LSP.
Ughhh. I agree that is ugly, but I'd argue that's down to bad design. A client should be given the bare minimum of what it needs to do it's work and no more.
My main complaint regarding interfaces is the inability to specify constraints on construction (e.g. an implementing class must supply a constructor with these parameters).
For example, if I have a generic Presenter class that manages a View, it would be nice to be able to write code like this
[source lang="csharp"]
TPresenter<TView> BuildPresenter(TView view)
where TView : IView
where TPresenter<TView> : IPresenter<TView>, new(TView) // doesn't exist in C#
{
var presenter = new TPresenter<TView>(view);
// do some work with presenter
return presenter;
}[/source]
You can already specify a parameter-less constraint, I don't see why that couldn't have been extended. Would save creating factory classes.