Instantiating a class implementing an interface
<p>I have an interface called <code>Cell</code>. In the start of the code, I read input data from which I can come to know the implementing class (not as a class object but I can know for example the string). And after that I need to call the constructor for the implementing class to initialize an object.</p>

<p>What would be the best way to implement that. The first thing in my mind is to do something like this (<code>Cell</code> is an interface, <code>Sphere</code> and <code>Rectangle</code> implements <code>Cell</code>. I can set a boolean flag called <code>sphere</code> after reading the input data):  </p>

<pre><code>Cell startcell;
if (sphere)
    startcell = new Sphere(0);
else
    startcell = new Rectangle(0);
</code></pre>

<p>But is this good design?</p>
