Created
September 30, 2010 04:36
-
-
Save kkozmic/604033 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IFoo | |
{ | |
void Foo(); | |
} | |
public class Base:IFoo | |
{ | |
public void Foo() | |
{ | |
} | |
} | |
public class Inherited: Base, | |
IFoo // <-- why/when would you want to do it? | |
{ | |
} |
If you would use reflection then under certain circumstances it could be handy.
And if you would like to implement the interface explicitly.
I can't think of a single reason to do this. Even if you can come up with some technical corner case where it may seem necessary (e.g. explicit interface implementation) it violates the Principle of Least Astonishment, so is a design smell. If you need to override the behavior of Foo, make it virtual in Base. If you don't own Base, create a Decorator instead of deriving from Base.
Yes, this is design smell and I would never use them. I wrote just technical reason why someone would want to do it :-)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Never, it is redundant. ReSharper suggests to remove line 14.