Question: What's reflection, and how have you used it to solve a problem?
Answer: Reflection is a way to look at assembly metadata and look in and see what is contained. It also allows you to use late binding and call methods within those assembles.
For the second part, a simple explanation is all you need to show that you understand how it is used.
So what if you've enver used reflection? First, shame on you (kidding!). It DOES serve a very important purpose and allows for some great solutions, especially at an architectural level. If you've never used it, I recommend immediately trying it out, and you'll find many, many uses. Here's a tutorial I found that looks decent. That way, when asked this question (and I get this one a lot) you can answer how you *might* really use it. Honestly, you've probably used it and didn't realize it if you've added certain attributes to your code.
I have used reflection for everything from identifying certain classes and functions. For example, for a coding sample, I used LINQ for Reflection and attributes to identify classes which supported certain calculations. By doing this, I could add more functions dynamically and the UI would pick it without changing code. Since LINQ for Reflection is not discussed much, I'll post some about that later.
There are some costs associated with Reflection though. Speed! Late Binding is slower by it's nature, as well as all the processing looking for methods, so plan and use wisely!
Powered by: newtelligence dasBlog 2.3.9074.18820
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2012, © Copyright 2010
E-mail