I recently had a conversation with one of my experienced spring developers. One person said that he used xml based configuration in a large project sometime back. How ever according to him the number of xml files written went out of hand with the growth of the code base. So in this regard it is good to have annotation driven codes to address this problem.
How ever sometimes using annotations is not good. becase annotations are not a part of the code. So in that regard, yes annotations are bad. Also unlike xml method, if you want to change a setting, then you have to edit the source and recompile it. Another point is
say you need to have several beans of the same class in your project with different states. Then clearly the xml based configuration wins over the annotations.
But having said that, annotation driven method has it's own benifits.
- reduces the number of xml files generated
- easy to maintain when the project is large and when you have a big software team
- It makes sense to use annotation particularly in some scenarios like transaction handling etc...
- Makes the developers aware of what each class does.
- Unlike xml method annotations are type-safe
Again you may argue that we can organize the growing number of xml files into one file and export them. But it would not be a good idea when it comes to controlling the developing cycle. Also maintaining will be a big issue.
In my point of view it has to be a mix of both. But try to use annotations as much as you can in order to make the developer life easy.
No comments:
Post a Comment