Downcasting
From Wikipedia, the free encyclopedia
In object-oriented programming, downcasting or type refinement is the act of casting a pointer or a reference to a base class to one to a derived class.
In most programming languages, it is usually possible to check through RTTI whether the type of the referenced object is indeed the one being cast to or a derived type of it, and thus issue an error if it is not the case.
[edit] Criticism
Many people advocate avoiding downcasting, since according to the LSP, an OOP design that requires it is flawed.
A popular example of a badly considered design is containers of top types, like the Java containers before Java generics were introduced, which requires downcasting of the contained objects so that they can be used again.