Wednesday, May 23, 2007

[Arch] "Evil" XML in Dependency Injection

We had a discussion recently in this Blog about dependency injection frameworks. Benedikt introduced the new kid on the block: Guice.

Was XML the solution for virtually everything some years ago, so it is apparently the fashion of the day to criticise XML applications in various domains, also in the usage as beans-configuration in Spring. I personally cannot really follow that discussion, for me personally particularly the usage of XML in the configuration of Spring was a very powerful advantage. It is a very declarative approach, meaning, one can easily provide a set of different configurations, simple properties (like jdbc urls and the like) can be easily externalised into properties files. Hence a clean multi stage configuration is feasible.

Additionally the config file can be easily edited with a variety of XML editors and given a simple XSLT script a HTML visualisation of the connections within the Spring definition is possible.

Right, so far my plea for XML-based dependency injection configuration.

However, there are folks who prefer other types like annotation based DI, and meanwhile also Spring supports XML-less DI declaration, partly also based on auto-configuration (which I on the other hand do not like at all; it easily confused configuration imho).

Several articles and Blog entries explain how to use Spring without "evil" XML, no need to repeat it here, check out for example:
Comments anyone?

No comments: