What exactly is Reflection and when is it a good approach?

前端 未结 11 1700
天命终不由人
天命终不由人 2020-12-25 14:58

What exactly is Reflection? I read the Wikipedia article on this subject and I understand that it is a kind of meta-programming, where the program can modify itself at run-

11条回答
  •  猫巷女王i
    2020-12-25 15:05

    Reflection is useful for runtime configuration, allowing parts of a system to be driven through external configuration.

    For example, a class factory could construct different concrete types based on an input file, where the concrete types require different configuration information to call a concrete constructor rather than using a builder interface. (The constructor method of the object being located using reflection).

提交回复
热议问题