• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XML based config vs annotations

 
Piotr Nowicki
Ranch Hand
Posts: 611
1
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy Ranchers!

I guess this might be also treated as a more general discussion, but: recently there was a increased number of things you can configure using annotations (i.e. JEE 6), like Servlets, url mappings, etc. The point is, the annotations are compilation-time feature, and XML is run-time.

So, all those unique, decalrative features i.e. runtime servlet mapping url change is vanished...

So, my question is: do you prefer annotations over XML, or the other way around.
Or maybe you have found a golden ratio, like: use XML for things that frequently changes (or are more likely to change) and annotations for more firm configuration.

Thanks in advance for your replies :-)

Cheers!
 
Piotr Rzexniczak
Greenhorn
Posts: 4
Eclipse IDE Linux Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Many of frameworks, libraries and other type project allows you to use both: annotations and xml configuration with the higher priority of xml configuration (I mean xml overrides annotations).
So you can safely use annotations during the development phase and if there is a need to change the configuration, you can do this in additional xml file later without recompiling your code.
 
Piotr Nowicki
Ranch Hand
Posts: 611
1
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And that sounds like a golden ratio for me.

Thanks Piotr!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic