Skip to content

Reflection Trade-offs

Question

Are there any downsides to reflection?

Short interview answer

Reflection reduces compile-time checking, can add runtime overhead, complicates refactoring, and may require extra configuration for trimming or ahead-of-time compilation.

Detailed answer

Reflection is appropriate when metadata-driven behavior is genuinely needed, but ordinary static calls are safer and clearer when types are known. Invoking members by name moves errors from compilation to runtime. Reflection-heavy code can also be harder for tools to analyze, so deployment modes that remove unused code need explicit metadata-preservation rules.

Sources