1) When you want to provide your code with some additional information (metadata).
2) Annotations per se are not very useful. However, they can be very helpful when combined with tools that can use the information they provide. E.g. you can annotate some methods of your class to be used only for testing purposes (hence, JUnit can use that information).
3) No, they don't affect the way your code compiles/executes (meaning functionality of your class or method cannot be changed just because you add annotation).
Thennam Pandian wrote:If you think the above link has answer for my questions, Could you please give the answer for each questions.
If it does have the answer to your questions, why should we simply repeat its contents here? If it doesn't - or you can't follow the explanation - then you need to be clear about what it is you don't understand. Nobody is going to provide an "annotations tutorial" in a couple of paragraphs.
Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Joined: Oct 11, 2005
If everybody can understand everything from the reference link or tutorial , then what is the need of this forum?
I think annotations are very good to do that sort of thing. After all, you're telling a tool something about your code, so it can work with your code more easily.
One of the things I was referring to, is how in JAX-RS you tell the framework which method it has to run when a specific event occurs using an annotation above that method signature. That's just *wrong*. We have interfaces for that.
Stephan van Hulst wrote:Annotations in my opinion should only be used for tools to inspect and perform actions on source code. They should not be used to make code itself run differently.
I really hate frameworks that use annotations to make the code run. As an example, in my opinion JAX-RS is a huge offender.
How about Transactional annotations, DI annotations?
Sure, runtime annotations introduce a new paradigm in Java, but I don't think it is a bad thing. It requires developers to shift their thinking, and introduce a learning curve, but that's not the worst thing in the world.
Thennam Pandian wrote:If everybody can understand everything from the reference link or tutorial , then what is the need of this forum?
If reading that reference link doesn't help you understand, it's highly unlikely that reading a post on this forum can make you understand. The reference is written by professional technical writers who spend considerable time thinking about how to present information clearly, and (over time) has been vetted by thousands of programmers.
Sure, it's understandable to have difficulty with certain aspects, and you are welcome to ask specific questions. However, before you do RTFM!
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com