Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What Are Main Advantages Of Annotations Over XML In Java [duplicate]

Possible Duplicate:
Xml configuration versus Annotation based configuration

Can some one let me know what are the main advantages of java Annotations over Xml, i heard meta meta always while searching about this in google, what that meta.

Thanks a lot.

like image 604
Siva Avatar asked Dec 01 '25 09:12

Siva


1 Answers

Meta data is some kind of description that you can supply along with your data. In java its possible to do with annotations, XML, there are other methods.

In order to take advantage of meta data you should have something that will process this data and decide what happens once the meta data is recognized.

Annotations have a lot of advantages over XML, to name a few :

  • Static type checking - the compiler will check for you where the annotation (once defined properly) is applicable and how

  • Clean code - its much easier to see (visually) the meta data defined in annotations

However it comes at a price:

  • XML doesn't require recompilation when you want to change something. With annotation you'll have to recompile.

Hope this helps

like image 157
Mark Bramnik Avatar answered Dec 02 '25 21:12

Mark Bramnik