Annotation Vs. Xml
People talk about putting meta information about a POJO through annotations, but it makes me wonder, how closely related my meta information should be?
Taking dip into Servlet 3.0 specification, annotations here seems to add value to Servlet classes because as responsibility of a servlet class is to process request and send response, it is also close to server end. Many things I'll write in a servlet will be close to container. Even if I write it in annotations or external XML files, I am not concerned about polluting my class with annotation that I'll have to carry everywhere I move my classes.
Now, in hibernate or JPA for instance, my POJO gets polluted with all the meta information that well suits in an external XML file. It keeps my POJO's clean from annotations. If I have to use a portion of the designed model somewhere else, I not bothered what goes in annotatons, its clean and meta information is externalized.
Percenatage of me reusing a servlet code to a domain object is more and makes life easier to keep POJO devoid of all meta information that can cause problem in future.
This is my view, it keeps things cleaner for me to work with and the usuall rant, makes unit testing easy without carrying framewrok burden.
To conclude there should be balance between how much annotation to use when and where.
Taking dip into Servlet 3.0 specification, annotations here seems to add value to Servlet classes because as responsibility of a servlet class is to process request and send response, it is also close to server end. Many things I'll write in a servlet will be close to container. Even if I write it in annotations or external XML files, I am not concerned about polluting my class with annotation that I'll have to carry everywhere I move my classes.
Now, in hibernate or JPA for instance, my POJO gets polluted with all the meta information that well suits in an external XML file. It keeps my POJO's clean from annotations. If I have to use a portion of the designed model somewhere else, I not bothered what goes in annotatons, its clean and meta information is externalized.
Percenatage of me reusing a servlet code to a domain object is more and makes life easier to keep POJO devoid of all meta information that can cause problem in future.
This is my view, it keeps things cleaner for me to work with and the usuall rant, makes unit testing easy without carrying framewrok burden.
To conclude there should be balance between how much annotation to use when and where.
Labels: annotation, spring, xml
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home