I went through all the posts on reflection but couldn't find the answer to my question.
What were the problems in the programming world before .NET reflection came and how it solved those problems?
Please explain with an example.
However, reflective thinking is most important in prompting learning during complex problem-solving situations because it provides students with an opportunity to step back and think about how they actually solve problems and how a particular set of problem solving strategies is appropriated for achieving their goal.
Reflection gives the brain an opportunity to pause amidst the chaos, untangle and sort through observations and experiences, consider multiple possible interpretations, and create meaning. This meaning becomes learning, which can then inform future mindsets and actions.
Reflecting helps you to develop your skills and review their effectiveness, rather than just carry on doing things as you have always done them. It is about questioning, in a positive way, what you do and why you do it and then deciding whether there is a better, or more efficient, way of doing it in the future.
The problem surfaces when one tries to predict the behavior of an individual by the behavior of the group of which the individual is a member. The problem is likened to the image of a person reflected in a mirror.
It should be stated that .NET reflection isn't revolutionary - the concepts have been around in other framework.
Reflection in .NET has 2 facets:
Investigating type information
Without some kind of reflection / introspection API, it becomes very hard to perform things like serialization. Rather than having this provided at runtime (by inspecting the properties/fields/etc), you often need code-generation instead, i.e. code that explicitly knows how to serialize each of your types. Tedious, and painful if you want to serialize something that doesn't have a twin.
Likewise, there is nowhere to store additional metadata about properties etc, so you end up having lots of additional code, or external configuration files. Something as simple as being able to associate a friendly name with a property (via an attribute) is a huge win for UI code.
Metaprogramming
.NET reflection also provides a mechanism to create types (etc) at runtime, which is hugely powerful for some specific scenarios; the alternatives are:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With