DEV Community

Discussion on: Coding Concepts - Reflection

Collapse
 
rafalpienkowski profile image
Rafal Pienkowski

Nice article Chris. Personally, I try to avoid reflection as long as it's possible. As you said, reflection is being resolved at runtime and if I made a mistake in the source code I'll know about it when I run my program on the test, UAT or production environment (this is pretty late in my opinion).
I like your real life example. I think it's very descriptive. If I have to face such a problem I'd like to use such kind of dynamic dependency injection with a configuration provided from a file or a database.
I don't want to say that reflection is an evil but we should use it very carefully because it's a two-edged sword.

Once again great post. Cheers.

Collapse
 
chris_bertrand profile image
Chris Bertrand

Thanks Rafal!