In absence of this pattern,
downcasting is needed in the derived classes. My question is does this pattern solve only the problem of
downcasting? And why is
downcasting bad compared to the alternative offered by Intelligent Childrean Design Pattern?
Intelligent children is used when there are two base classes at the root of separate but related class hierarchies. For example
WidgetRenderer are the base classes and
ListBoxWidget needs to be used by the
draw() method of the
ListBoxWidgetRenderer. So the
draw() method will want to downcast the
Downcasting is generally frowned on, so every fresh reader will have to be convinced that it's okay in a given situation. With this pattern the right pointer is made available at the right type.