title: Java design pattern for two classes sharing identical and similar but different methods
body: <p>Let's say my application has some services implemented as <code>ClassA</code> and <code>ClassB</code>. Both have some similarities but also differences.</p>
  
  <ol>
  <li>Both classes have a <code>start()</code> method with the same method signature but a different implementation.</li>
  <li>Both classes have a <code>process()</code> method with a different signature and a different implementation.</li>
  <li>Both classes have an identical <code>log()</code> method, i.e. the code is exactly the same.</li>
  </ol>
  
  <h3>Class A</h3>
  
  <pre><code>public class ClassA {
  
      public String start(String s1, String s2) {
          startImplementation();
          return someString;
      }
  
      public String process(String s) {
          processingImplementation();
          return processedString;
      }
  
      private String log(String s) {
          logImplementation();
          return sharedString;
      }
  }
  </code></pre>
  
  <h3>Class B</h3>
  
  <pre><code>public class ClassB {
  
      public String start(String s1, String s2) {
          otherStartImplementation();
          return someString;
      }
  
      public String process(Long l) {
          otherProcessingImplementation();
          return processedString;
      }
  
  
      private String log(String s) {
          logImplementation();
          return sharedString;
      }
  }
  </code></pre>
  
  <p>I'm having trouble thinking of a "design pattern" how I could organize this in a more generic way. As of 3. I could easily move this method to a superclass which <code>ClassA</code> and <code>ClassB</code> extend. But how would/could I design the application so that 1. and 2. are also taken into account?</p>
  
  <p>Item 1. sounds a little bit like an interface to me but I don't have any idea how this could be combined with the superclass for item 3. And what about item 2?</p>