Meta data is some kind of description that you can supply along with your data. In java it’s 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. It offers ‘Static Type Checking‘. This helps the developers in catching most of the errors at ‘Compile Time’ and keeping the production systems functioning with minimal errors.
- Clean code – It’s 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.
- Annotations are attached to classes and can be processed via reflection. XML has to be parsed with some library. Main feature of annotations are that they are created at compile time and cannot be changed afterwards – if you need flexible configuration you shall stick with xml / other means.
@Annotations