title: Implementing a custom clone/copy capability: abstract or interface?
body: <p>As I've learned that it is not advised to implement <code>ICloneable</code> (<a href="https://stackoverflow.com/questions/699210/why-should-i-implement-icloneable-in-c">due to the fact that it does not differentiate between Deep Copy or Shallow Copy</a>), I'm trying to determine whether I should implement it as an abstract or an interface.</p>
  
  <p>I feel that my implementation would stay largely the same, e.g. a <a href="https://stackoverflow.com/questions/4152733/how-to-implement-clone-and-copy-method-inside-a-class">binary deep copy</a> and a <a href="http://msdn.microsoft.com/en-us/library/system.object.memberwiseclone.aspx" rel="nofollow noreferrer"><code>MemberwiseClone</code> shallow copy</a>, so to that end I felt that an abstract method would be ideal. However, my understanding is also that C# does not do Multiple Inheritance, thus if I ever need to use <em>another</em> abstract class, then I no longer can.</p>
  
  <p>In that case, I feel that implementing a custom <code>ICloneable</code> (e.g. <code>ICustomCloneable</code>) would be the better option, but if the implementation is effectively the same across many classes, I feel like I'm not adequately taking advantage of code reuse.</p>
  
  <p>That being said, is it valid to use an interface to keep the abstract inheritance clear for more important things in my cloneable classes? Or is there another way to do this? </p>
  
  <p>Alternatively, is it valid (read: not smelly) for an abstract to implement another abstract? This would be my guess as to getting around the single-inheritance that prevents me from implementing the CloneCapable class as well as another abstract, but it sounds like it might be questionable. e.g.:</p>
  
  <pre><code>public abstract class CloneCapable
  {
    public object ShallowCopy()
    {
      // implementation
    }
  
    public object DeepCopy()
    {
      // implementation
    }
  }
  
  public abstract class ClassA : CloneCapable {}
  
  // abstract-abstract since I can't do ClassB : ClassA, CloneCapable
  public abstract class ClassB : ClassA {} 
  </code></pre>