title: hiding implementation details through the usage of protected virtual
body: <p>A coworker introduced me to the concept of hiding implementation details through allowing the derived class to override the private field initializations. </p>
  
  <p>For example I have a base class:</p>
  
  <pre><code>public class Animal
  {
     private Dog dog;
     private Cat cat;
     private Mouse mouse;
  
     protected virtual void Init()
     {
        dog = new Dog();
        cat = new Cat();
        mouse = new Mouse();
     }
  
     public void DoStuff() {}
  
  }
  </code></pre>
  
  <p>This allows me to override the initialization within a derived class of the base class privates:</p>
  
  <pre><code>public class Cookie : Animal
  {
     protected override void init()
     {
        //do whatever i want here
     }
  }
  </code></pre>
  
  <ol>
  <li>Does this type of implementation-detail-hiding have a name?</li>
  <li>Would I ever call Init() from Animal or does this pattern insist on Init() because called from a derived class?</li>
  </ol>
  
  <p><strong>What am I trying to achieve?</strong></p>
  
  <p>I have a class (animal in the example above) that has about 20 private objects that need to be initialized, and I want to be able to define my own way of initializing them specifically when doing unit testing. </p>