
3 Jul
2009
3 Jul
'09
9:15 a.m.
2009/7/3 Luke Palmer
Keep in mind that with this solution *and* with the ExistentialQuantification solution, there is no possibility of downcasting. I.e. if you were planning on making a GraphicalWidget subclass, and them somewhere seeing if a a Widget is actually a GraphicalWidget, you will be disappointed. The solution in this case is to redesign your software not to need downcasting. This is the point at which you are forced to move away from OO thinking.
Heck, as far as I'm aware most OO communities frown on downcasting too. The "OO approach" is to call a virtual method and let the object decide to do, which (with enough hand-waving) is basically what you end up doing here anyway. Stuart