Reputation: 1199
I intend to use the Pugh Decision Matrix to analytically reach a decision on this long running debate about the best approach (only with an academic interest though, it will be difficult to take sides).
I invite you to suggest appropriate criteria for the comparison between these two approaches.
Upvotes: 0
Views: 1339
Reputation: 1
Simple if you want the code to be
-Tightly coupled (developer should understand the flow of application well {i.e. readability} and easy for upgradation/enhancement) use annotation- <b>Loosely coupled</b> and configs used across the application <b>use XML</b>
Upvotes: 0
Reputation: 1199
I came up with the following criteria (numbers in square brackets signify the weightage on a scale of 10, a higher number indicates greater importance):
Upvotes: 0
Reputation: 21186
My suggestions for Criteria:
But it's an interesting exercise though ultimately it does depend on the context and purpose of the beans you're creating.
For example, in the context of spring and annotations: To configure lots of "workhorse" beans (standard beans which don't require customisation or access to 3rd party resources) annotations wins hands down. I know, I had to use xml to configure these and it was a nightmare, fortunately we had pseudo annotations in the form of xdoclet that helped. The key differences here is that when using annotations you don't have to specify the details of the class, that is known already.
But then another context where I want to configure the beans; change properties, plugin a different bean, create instances of already existing classes, access 3rd party resources (jndi resources etc) or configure an entity manager - xml is the only way to go. In this context I typically don't have access to the source code of the class, I'm creating beans from libraries.
Upvotes: 2
Reputation: 32831
On the annotation side:
On the XML side:
Upvotes: 3