Interface + Base Class
Oren Ellenbogen has posted about generic constraints in the case where you have both an interface and a common base class. I tend to use the same Interface + Default base class often enough in my code.
The issue I have with this is whatever the interfaace is even needed? I often find myself extending only from the base class and never directly from the interface.
Take for instance the MethodRecorderBase and IMethodRecorder from Rhino Mocks. Everythings works against IMethodRecorder, but all the concrete classes are decendants of MethodRecorderBase. In this case, whenever I need to add a method to the Method Recorders family, I need to update both the interface and base class (and maybe the sub classes).
Just to be clear, I'm not saying the the general principal is wrong, it is a defintely a Good Thing in certain cases (ICollection & CollectionBase come to mind), but I wonder about its usage when you start with new code.
Isn't this a violation of both DRY and YAGNI?
Comments
Comment preview