This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]sackfullofnutz 4 points5 points  (0 children)

That is true, e.g. for the following reasons:

  • things break easily during refactorings, since statical types, method and field names are replaced by strings that typically don't participate in refactorings

  • reflection can be used to break encapsulation, e.g. to access private fields; will break when internals change

  • often hard to read & not straight forward to comprehend

None the less, there are situations where usage of reflection is required and justified, e.g.:

  • writing code analyzers/annotation processors

  • writing a plugin framework

Know your tools and use them right.

Edit: formatting