Discussions

Web tier: servlets, JSP, Web frameworks: How useful is Java Annotations?

  1. How useful is Java Annotations? (2 messages)

    I want to start this discussion and get your views on usefulness of Java Annotations. Here are my concerns: - Few years ago it was said XML is good for configuration management... as it is external to system and we dont need to rebuild code and blah blah things Now we are saying: -- There are too many external configuration which is bad and so Annotations are good... So using Annotations- - Aren't we loosing the liberty of externalizing configuration management. - Also we are tying a class with Annotation to AnnotationClass...Isnt it breaking design pattern rule of loose coupling. - Reusing a class if a class is associated with a particular Annotation and tommorow if we want to use the same class in some other environment I think we either need to rebuild the class or rewrite a seperate class with similar attributes/methods What is your opinion on Annotations
  2. Annotation is meta data about that perticular class. Lets take example of all new Annotation in EJB3.0 which makes life easy as compare to ejb 2.0. About XML for configuration. it is still used. if you write xml file it will ignore the annotation meta data. So annotation is to make complex things easy. I did not understand your point on reusing the class, why can't we use same class tomorrow.
  3. The question is valid and interesting. It is important to differentiate between configuration (as something that can be configured by an end user) and meta programming (as something that is related to actually development, that is known and can be verifed at compile time). Question: Aren't we loosing the liberty of externalizing configuration management? Answer: Such an externalization can be achived by using XML configuration. But it can also be achieved by using an interface with multiple classes, where different classes have different annotations. Question: Also we are tying a class with Annotation to AnnotationClass...Isnt it breaking design pattern rule of loose coupling? Answer: Again, if we use interface/implementation technique, we can end up with a clean interface and implementation with annotations. With this approach you can replace an XML-based implmentation to annotation-based and vice versa. Question: Reusing a class if a class is associated with a particular Annotation and tommorow if we want to use the same class in some other environment I think we either need to rebuild the class or rewrite a seperate class with similar attributes/methods. Answer: Once again, by using interface/implementation separation approach we can achieve independence from the underlying configuration and the way configuration is applied. Java Development on Demand http://www.hitech.com.ua/en/