title: Which SOLID Principles are violated?
body: <p><strong>INTRODUCTION</strong></p>
  
  <hr>
  
  <p>I work on my master thesis about inheritance problems and work out some
  indicators which show that an inheritance problem exist.</p>
  
  <p>Like the following example:</p>
  
  <p><strong>EXAMPLE</strong></p>
  
  <hr>
  
  <pre><code>public static String getAnimalNoise(Animal animal) {
    if (animal instanceof Dog)
      return "Woof";
    if (animal instanceof Cat)
      return "Miau";
    return "";
  }
  </code></pre>
  
  <p>The method returns the String <code>"Woof"</code> if the given Animal instance is a <code>Dog</code> and <code>"Miau"</code> if it is a <code>Cat</code>. The empty string because some animals make no noises at all. </p>
  
  <p>So the correct solution for that should be use polymorphism with a <code>getNoise</code> Method in the Animal class.</p>
  
  <p>I have analysed different indicators of inheritance problems and want to say if
  some of them violates a <a href="https://stackoverflow.com/tags/solid-principles/info"><strong>SOLID</strong> Principle</a>.</p>
  
  <p>I thought the example above violates the:</p>
  
  <ol>
  <li><strong>Single responsibility principle (SRP)</strong></li>
  <li><strong>Open/closed principle (OCP)</strong></li>
  <li><strong>Liskov substitution principle (LSP)</strong></li>
  <li><strong>Dependency inversion principle (DIP)</strong></li>
  </ol>
  
  <p>But i'm not really sure whether it is true for all.</p>
  
  <p>I thought:</p>
  
  <p><strong>PRINCIPLE VIOLATIONS</strong></p>
  
  <hr>
  
  <p><em>SRP Violation</em></p>
  
  <p>Because conditional statements at all violates the <em>SRP</em>, because like the switch 
  case statement or more than one if-else statement are consider more than one responsibility. </p>
  
  <p>It exists two cases so there are more than one reason to change the method.</p>
  
  <p><em>OCP Violation</em></p>
  
  <p>Because if a new animal is added a new case must be added to the method
  so the Method is not close for modifications.</p>
  
  <p><em>LSP VIOLATION</em></p>
  
  <p>Each branch executes different actions dependent of the animal sub type.
  Which i think violates the <em>LSP</em> ?!
  I know the example of the rectangle and square and the getArea but these
  example i thought fits also to the violation.</p>
  
  <p><em>DIP VIOLATION</em></p>
  
  <p>The conditional statements take dependency that means the statements are dependent on details and not on abstractions which violates the <em>DIP</em>.</p>
  
  <p><strong>QUESTION:</strong></p>
  
  <hr>
  
  <p>So the Question is, for the given example, are the given principles really violated and is the reasoning correct?</p>