If reflection is inefficient, when is it most appropriate?

前端 未结 7 450
野的像风
野的像风 2020-12-05 19:44

I find a lot of cases where I think to myself that I could use relfection to solve a problem, but I usually don\'t because I hear a lot along the lines of \"don\'t use refle

相关标签:
7条回答
  • 2020-12-05 20:10

    Reflection is not inefficient. It is less efficient than direct calls. So personnaly I use reflection when there's no equivalent compile time safe method. IMHO the problem with reflection is not so much the efficiency but the fragility of the code as it uses magic strings which are very refactor unfriendly.

    0 讨论(0)
提交回复
热议问题