Externalize rendering of polymorphic objects
<p>Let's say we have a classical polymorphic architecture :</p>

<pre><code>class Animal
{
    virtual void eat() = 0;
};

class Frog : public Animal
{
    virtual void eat() { ... }
};

class Chipmunk : public Animal
{
    virtual void eat() { ... }
};
</code></pre>

<p>This is fine. But when it comes to rendering, I could add a virtual <code>render</code> method to the <code>Animal</code> base class just like the <code>eat</code> method.</p>

<p>But then animals source files have dependencies to the particular library that is being used. This doesn't make things modulable and maintainable. Plus, their rendering code basically doesn't concern them.</p>

<p>What is a nice way of putting the render specific code out of the derived classes ? </p>

<p>When I say nice, I mean without using something like an overloaded method that returns a different number for each derived class so I can do a big <em>if...else if ...</em>.</p>
