Reflection and Introspection considered harmful
807607Nov 10 2006 — edited Nov 12 2006I have an opinion on the use of introspection and reflection, but it does not seem to be echoed anywhere else, so I wonder if I'm not getting it.
I understand that it can save you a massive amount of time when coding (i.e. buy calling your methods by certain names they get called "as if by magic" eliminating the need for explicit calls), but here's my bug bear....
Does Introspection and Reflection lead to unmaintainable code?
In the olds days you could trace through your code line by line, going from one function to the next and so on, you knew what called what and when.
With reflection (particuarly if you use third party API's) you could look at some code, not understand where it fitted into a framework and functions get called "as if by magic", just because they have been named a certain way. Is this not obfuscating things?
I think there is a danger that in the future some frameworks will have gone out of fashion, books explaining them will have gone out of print and their websites not be maintained, we'll be left with a ton of code that no-one knows how to maintain because too much has been hidden away.
I understand the need for reflection etc for debuggers/profilers I think it creates unmaintainable code for "normal" apps.
What does everyone else think?