title: FactoryPattern to construct objects
body: <p>The question is about <code>GoF</code> interpretation of the Factory pattern.</p>
  
  <p>I have a <code>Tree&lt;SqlRestriction&gt;</code> where </p>
  
  <pre><code>public interface SqlRestriction{
       public String getSql();
  }
  </code></pre>
  
  <p>Now, I need to create an object of the interface called Container:</p>
  
  <pre><code>public interface Container{
      //methods
  }
  </code></pre>
  
  <p>Here is one of its implementation:</p>
  
  <pre><code>public class SimpleSqlListContainer implements Container{
      private Integer rate;
      private String relation;
      //GET, SET, CTORs, other methods
  }
  </code></pre>
  
  <p>So, I tend to wrap the objects creation into a factory </p>
  
  <pre><code>public class ContainerFactory{
      public Container create(Tree&lt;SqlRestriction&gt; restrinctions){
           //impl
      }
  }
  </code></pre>
  
  <p>The actual creation as well as <strong><em>proper initialization</em></strong> are going to be performed by traversing the <code>Tree</code> passed as a parameter.</p>
  
  <p><strong><em>QUESTION:</em></strong> If I initialize the object that is being created within the factory method, would it be considered good. Or it can mislead other developers? So, in factory method, should we avoid any kind of initialization and just perform the object creation, leaving the initialization to the client. </p>