bio photo

I am refactoring Nifty-GUI's internal workings. Trying to make it less inheritance dependent.

To manage all the Elements (Panels, Images, Text and so on) I have quickly and with not much thought introduced a Element class hierarchy as shown in figure 1.

<img src="http://nifty-gui.lessvoid.com/images/remove-inheritance-before.png" alt="figure 1: reasonable (?) class hierachie" border="0" height="128" hspace="2" vspace="2" width="141" />

figure 1: reasonable (?) class hierachie </strong></p>

Well, each Element has an "void abstract render()" method to render itself. This method is overwritten in the subclasses. This is reasonable because the steps you'll need to render an Image are probably different to f.i. a TextElement. You have seen this kind of solution a million times before. So why should this be a bad thing?

Alex Miller points in his Blog the drawbacks of the Template Method out (see his very cool entry here: Alex Miller - Pattern I Hate #2: Template Method</a>). And although this is not really a Template Pattern in it's purest form it sure has most of the drawbacks as Alex points out, for instance:</p>