I came across the following code in our code base:
public interface ICloneable<T>
{
T Clone();
}
public class MyObject : ICloneable<MyObject>
{
public Stuff SomeStuff { get; set; }
T Clone()
{
return new MyObject { SomeStuff = this.SomeStuff };
}
}
The pattern of using a generic interface and then doing class A : Interface<A>
looks pretty bizarre to me. I have a feeling it's either useless or that it could be changed into something less intricated.
Can someone explain if this is right/wrong, and how it should be changed?
Clone
should returnMyObject
notT
. \$\endgroup\$