开发者

Bad use of java annotation [closed]

开发者_StackOverflow社区 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 11 years ago.

I know java annotation is a powerfull tool. For me, project lombok is a great example of extreme use. But i've heard that sometimes, it is better not to use annotations.

Can you give me examples of bad annotations, so i have an idea of what to avoid ?


It's like asking in which situations a spoon isn't useful.

Instead it can typically beneficial to use annotations when

  • You're constructing a framework which will be used by many components.

    • For instance I once made a gui framework and added annotations such as @CSS etc.
    • Hibernate provides in my opinion a great approach to annotation based database mapping
  • You need to perform some compile-time task, like generating javadoc.

  • Dependency injection
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜