Paul Clapham wrote:I would say your design is wrong. If you have something which should work differently for each subtype of a certain parent, then that's a sure sign you should be using inheritance and polymorphism. In other words, it's the Renderable class (or interface?) which should declare the doWork() method and each of the subtypes should implement that method in the way appropriate for that subtype.
I would agree but at some point all of these types will have to converge. Some will turn into strings and others will be turned into binary that a user can download. So I'm not sure as to how to get that piece to work. Design-wise that is.