title: Dependency injection with abstract class
body: <p>I am struggling for last two days to get a grip of DI.</p>
  
  <p>I have two problems:</p>
  
  <ol>
  <li>If I have a some common functionality why I can't do the same thing implementing DI with an abstract class?</li>
  <li><p>In my example I have many class instance created under writefile, so should I move out all object creation from there? What if I have a layered design? Should these classes be passed all along?</p>
  
  <pre><code>public interface IWriteFile
  {
      void write();
  }
  
  public class WriteXMLFile : IWriteFile
  {    
      public void write()
      {
  
      }
  }
  
  public class writefile
  {
      IWriteFile _file;
  
      public writefile(IWriteFile file)
      {
          _file = file;
      }
  
      public void WriteMyFile()
      {
          _file.write();
      }
  }
  </code></pre></li>
  </ol>