title: Should a parent class ever reference child classes?
body: <p>Good morning,</p>
  
  <p>I inherited some legacy code at work and it is using a rather unusual design pattern. The only reference I could find on the forums to a similar pattern was <a href="https://stackoverflow.com/questions/1387207/can-a-parent-call-child-class-methods">here</a>. The situation is that the original designer has a generic parent class (not abstract) that has a static factory method which directly references children classes.</p>
  
  <p>Here is a sample of that style of coding, found in several places in the legacy code:</p>
  
  <pre><code>public static LoggerFactory getLoggerFactory(LogType type) {
      switch (type) {
      case LOG4J:
          return Log4JLoggerFactory.getInstance();
      case LOGBACK:
          return LogBackLoggerFactory.getInstance();
      default:
          throw new RuntimeException("No logger factory defined for type " + type);
      }
  }
  </code></pre>
  
  <p>Where Log4JLoggerFactory and LogBackLoggerFactory extend LoggerFactory.</p>
  
  <p>This seems really foreign to me but before I re-factor the code significantly, is there any purpose or benefit to this design pattern (is there even a formal name for it)?</p>
  
  <p>Any thoughts or advice is appreciated. Thanks!</p>
  
  <p>EDIT: After reading Yishai's response, I thought I would include a link to the <a href="http://en.wikipedia.org/wiki/Strategy_pattern" rel="nofollow noreferrer">Wikipedia article on the Strategy pattern</a>, for easy reference. Thanks to everyone for your responses!</p>