Motivation for Using Static Factory Methods
<p>The motivation for using Static Factory methods staes as:</p>

<blockquote>
  <p>The most obvious motivation for Replace Constructor with Factory
  Method comes with replacing a type code with subclassing. </p>
  
  <p>You have an object that often is created with a type code but now
  needs subclasses. The exact subclass is based on the type code. </p>
  
  <p>However, constructors can only return an instance of the object that
  is asked for. So you need to replace the constructor with a factory
  method.</p>
</blockquote>

<p>Can anyone please explain this with code? And what does this <strong>type code</strong> mean?</p>
