BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News InfoQ Article: The Annotation Hammer

InfoQ Article: The Annotation Hammer

This item in japanese

In this latest InfoQ article, Venkat Subramanium (author of Practices of an Agile Developer) takes a look at Java SE 5 Annotations. What they are, how to create them, and more importantly, how to use and not misuse them.  "The right use of annotations" is a design concern that deserves due consideration in application development - neither blind acceptance nor rejection of it is a good idea.

Read The Annotation Hammer.
"If the only tool you have is a hammer, then everything looks like a nail," goes a saying. While annotations are a good tool, not every situation warrants their use. Most of us have come to dislike XML configuration. However, suddenly, everything in the XML configuration shouldn't become annotation.

Use annotations for what you want to express intrinsically in code. For example, the @Persist annotation in Tapestry is a good example. You want to declare a property of a bean as persistent and Tapestry will take care of storing it (in the session for instance). I would much rather define this as annotation than using a verbose configuration to say the same. The chances are, if I decide not to make the property persistent, much is going to change in the code anyways.
How have you been using Annotations on your projects?

Rate this Article

Adoption
Style

BT