title: Multiple parameters in Factory Method Pattern
body: <p>I'm trying to use Factory Method Pattern to create different objects, but i have several doubts. Let me show you the scenario:</p>
  
  <pre><code>public class ObjectFactory{
  
      public static IObject createObject(Param1 p1, Param2 p2, Param3 p3){
          if (p1.getName('name1')){
              return new Object1(p1,p2,p3);
          }else{
              return new Object2(p1, p2);
          }
      }
  }
  
  public interface IObject{   
      void doSomething();
  }
  
  public class Object1 implements IObject {
      public Object1(Param1 p1, Param2 p2, Param3 p3){}
  }
  
  public class Object2 implements IObject {
      public Object1(Param1 p1, Param2 p2){}
  }
  </code></pre>
  
  <p>Im a bit confused with the Param3 in the ObjectFactory's createObject method. I always have this param, but sometimes it makes no sense. 
  I don't like this because if some day I add more objects with different params, I will need to add too many params to the method signature. </p>
  
  <p>I was thinking in defining:
  public static IObject createObject(Param1 p1, Param2 p2, Param3 p3) 
  public static IObject createObject(Param1 p1, Param2 p2)
  but then it isn't a Factory Method Pattern, because invoker must know which method has to be executed.</p>
  
  <p>Do you know any solution to deal with this?  </p>
  
  <p>Thanks in advance.</p>