![]() |
![]() |
![]() |
definition of reflection I keep hearing people talk about reflection and .NET. I am a C/C++ guy, so this term is foreign to me. From what I gather it just means obtaining what is typically compile-time info in C/C++ at runtime in other languages. Like inheritance hierarchies, variable names, source code for functions, etc. Is this the correct definition?
Roose
Yes.
Li-fan Chen
Not just obtaining that information, but usually you can use it in an IDispatch sort of way. E.g. in Java, you can get a list of an object's methods, search them by name, and then invoke one (passing it the required args). Sort of a clumsy "eval".
Brian
It's also REALLY useful when building "plumbing" - automatically building proxies, serialization code, etc.
Chris Tavares
Actually most of it can be done in C++.
Katie Lucas
Reflection should be a language feature, not an API.
fool for python
In Java, reflection lets you start with the name of a class and then create an instance of the class and invoke its methods. I've found it useful when I want to include a class name in a configuration file, so my code can instantiate any class that implements a particular interface.
Julian
|