title: Sad logic on types
body: <p>Code base is littered with code like this:</p>
  
  <pre><code>BaseRecord record = // some BaseRecord
  switch(record.source()) {
      case FOO:
          return process((FooRecord)record);
      case BAR:
          return process((BarRecord)record);
      case QUUX:
          return process((QuuxRecord)record);
      .
      . // ~25 more cases
      .
  }
  </code></pre>
  
  <p>and then</p>
  
  <pre><code>private SomeClass process(BarRecord record) { }
  private SomeClass process(FooRecord record) { }
  private SomeClass process(QuuxRecord record) { }
  </code></pre>
  
  <p>It makes me terribly sad. Then, every time a new class is derived from <code>BaseRecord</code>, we have to chase all over our code base updating these case statements and adding new <code>process</code> methods. This kind of logic is repeated everywhere, I think too many to add a method for each and override in the classes. How can I improve this?</p>