title: Java7 creating converter,Interface or static methods?
body: <p>In a project,I have classes A,B.I have to convert A to B and also B to A.There is two approaches to convert them:</p>
  
  <p>1- Creating an utility class with static methods like this:</p>
  
  <pre><code>public class converter{
      public static A convertBToA() {
          ...
      }
  
      public static B convertAToB() {
          ...
      }
  }
  </code></pre>
  
  <p>2- Creating an interface like this:</p>
  
  <pre><code>public interface Converter {
      public &lt;T&gt; T convert(Class&lt;T&gt; type, Object value);
  }
  </code></pre>
  
  <p>Then implement it by a class and override converter method to convert A to B and vise versa.I know both of above ways are possible,but I like to have a <strong>good design</strong>.So, which way is better?</p>
  
  <p><strong>Notes</strong>:</p>
  
  <p><strong>1-</strong> I use java 7,so Interface bodies can not contain static methods.<br>
  <strong>2-</strong> As <a href="https://stackoverflow.com/users/106104/immibis">immibis</a> commented here,Answer depends on situations.But I looks for ways that match Design Principles.Specially minimum time for maintenance and developing.</p>