Bad use of java annotation [closed]
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
精彩评论