More configurator than programmer
If you’ve ever tangled with a new technology, chances are
you had to configure it in some way. It probably comes as no surprise
that XML has taken root as a configuration format. It offers plenty of advantages here,
including validation, easy editing and a human-readable format.
Most Java products have taken the advantages of XML configuration to heart, so you seldom
see any other format. I’d divide configurations into three weight classes
by size. In the first, which I call flyweight, are supposedly
simple utilities with up to 30 lines of configuration, such as the Log4J logging framework
or the Proxool database connection pool.
The second class, middleweight, covers configurations of up to 250 lines. Classic
examples are servlet configuration or, more broadly, web application configuration. This family also
includes the configurations of supposedly simpler tools such as Tomcat and Jetty,
HTTP servers and servlet containers.
The third class has no weight limit. For these tools you have to split the configuration
into several files to have any hope of keeping it manageable.
Examples include model-view-controller frameworks such as Struts and IoC containers
such as Spring and Pico.
I’m sure you can place the products you’ve configured yourself
in one of these categories. My examples won’t always fall into the same
category either. They can move both ways depending on the size of the project.
Another important factor is how configurations pile up. For a web
application you’ll need at least a servlet configuration and an MVC configuration. Your
application needs logging, and because it works with a database, it also needs a connection
pool. Add it up and you have at least four configuration files.
An extreme example is the Spring IoC container, where configuration connects
the application’s different layers. Another is the configuration of the JBoss J2EE server’s deploy
directory. EJB, for that matter, is also extreme in this respect. To exaggerate a little,
all that configuration could drive you mad. English has a fitting term
for it, metadata hell.
From an application’s point of view, XML configuration has a huge advantage. It saves you from
tying the components of the system together, or hard-wiring them, in code.
Today
there are plenty of tools, such as Ant and XDoclet, that can be a real help
and make configuration work easier.
Weighing the pros and cons, I think XML configuration comes out ahead,
even if it sometimes leaves me doing more configuration than
programming.
Related articles
Related CZ Podcast episodes
- #261 · Leadership
On leading people and teams. · Czech audio
- #3 · Java 6 SE, Vývoj webových aplikací
Dagi and Filemon discuss Java 6 and web application frameworks. · Czech audio
- #1 · Vývojová prostředí v Javě
The first CZ Podcast episode looks at Java development environments. · Czech audio