Java Reflection and the pain in Refactoring

后端 未结 9 1688
清歌不尽
清歌不尽 2021-02-08 14:25

Java Reflection provides a mechanism to introspect an Object at runtime. No second thoughts, this is a great feature, but it breaks all the Refactoring conventions!

Ther

9条回答
  •  广开言路
    2021-02-08 15:21

    Refactoring could be improved by introducing more "literals" in the language. E.g. imho .class literal are a great way to ensure compile-time safety of certain models. However the important thing to say here is that, sometimes, I want to lose compile-time safety. Strings are the most simple yet powerful way to express a loosely coupled contract between two layers since you can manipulate or match them against a regular expression, etc

    The real problem of reflection is the verbose use of the API. The is the major cost for flexibility.

    PS

    Project coin could introduce somewhere in the future some new language construct to enhance this area.

提交回复
热议问题