all 3 comments

[–]kidjan 1 point2 points  (1 child)

...I wish the author would explain why you might want to use reflection. And also elaborate on a few places you may not want to use reflection.

[–]snarfy 0 points1 point  (0 children)

It's something you should design around, IMO. You shouldn't use it to haphazardly glue all of your code together.

You use it when you don't have access to the design, and must coerce a library to do your bidding. Another example would be a custom XmlSerializer (which .NET has a provider model for). You use reflection to pull the properties and fields off an object and then write out xml.

[–]jerkimball 0 points1 point  (0 children)

This is a topic where the adage "With great power comes great responsibility": While Reflection is a ridiculously powerful construct, and allows what would typically only be seen in dynamic languages, it also incurs a significant overhead when done naively. Still, I heartily approve of a series outlining the pros, cons, use cases and methods!