Alan Burlison's Work Related Ramblings

All | General | Java | NetBeans | Perl | Solaris
« Why I hate XML confi... | Main | The birth of a new... »

20070503 Thursday May 03, 2007

XML-based J2EE frameworks considered harmful

Are you using one of the XML-based web frameworks such as Spring, WebWork or Struts?  Then you've been duped.  Conned. Flimflammed. Bamboozled. Hornswoggled.  (Yes, this is a rant ;-) Here's why:

I'm fully aware that the list above is crammed with generalisations, and that there are various hacks and workarounds for some of the issues.  However the overall point I'm making is that XML isn't a programming language, yet virtually all of the major J2EE frameworks use it as if it is.  The pervasive use of XML for tasks for which it is not suited has effectively discarded the last 30 years of software engineering advances. This is a huge mistake, and I expect that in 5 years time people will look back at the current XML mania and say "What the hell were we thinking of?"

Posted by alanbur ( May 03 2007, 12:44:05 PM BST ) Permalink Comments [5]

Trackback URL: http://blogs.sun.com/alanbur/entry/xml_based_j2ee_frameworks_considered
Comments:

If you are using Spring only for dependency injection (DI), you should consider using or at least testing Google Guice. It is an DI framework based on Java 5 annotations and completely avoids the usage of XML. This way, you will get all the benefits of type safety, compile time checking, ...

But I'm sure, that the time has come, that the Java people have a lesson learned: XML is just a good replacement for binary files and protocols, but not in any way a (source) language for programming or configuring.

Posted by Tobias Roeser on May 03, 2007 at 01:30 PM BST #

I both get your point and have to agree with a bunch of arguments in here, especially talking about rebuilding/redeploying .war files instead of "just" changing configuration. But after all, aren't we software developers, capable of doing jobs more difficult than "just" to wisely decide which tool to use and how much to make use of it? There probably are things that belong to some sort of configuration file, and there are some things that belong to code rather than configuration, I'd say. Spring+AOP+XML configuration is an incredibly powerful tool helping to keep code clean and yet keep track of how things work together... given one does it right. But in my opinion <em>that</em> is the very point: We should consciously decide which tool to be used for which solution, rather than blindly rely upon a "one-size-fits-all" approach. And, for that matters... Maybe we just have to make better solutions... What sort of approach instead of XML configuration would you prefer here, given not to have to mess with your code each time, say, you add/remove some AOP'ish service to it? Cheers, Kristian

Posted by kawazu on May 03, 2007 at 01:32 PM BST #

Tobias: I couldn't agree more with your last paragraph. Unfortunately I don't have the luxury of choosing a different framework. I'm working on a fairly substantial J2EE application that we are preparing to release as Open Source, trying to get it to build and run cleanly under NetBeans so that it is possible for other people to modify it easily - the current configuration and build mechanisms are arcane to say the least. I'm a maintenance programmer, for the purposes of this project, and it is a complete nightmare. Apart from the fact it uses two different J2EE frameworks (yes, really) and over 50 different external JAR files, the thing is an XML configuration file nightmare. All the tools that my IDE provides are useless as so much of the application structure is in XML files.

Kawazu: I agree that some things are OK in configuration files - paths, URLs and so forth. The problem is that the most significant parts of the application logic are in various XML files. As I already said, this renders most of the tools I have for grokking the application useless. I don't believe that Spring+AOP+XML does keep the code "clean", all it does is hide the messy bits in XML files - it's still a mess, but it is now a mess that is split over two different technologies, Java and XML, and two technologies that have a huge "impedance mismatch". I'd actually prefer to have all the configuration done in POJC (Plain Old Java Code), because that's what the XML goop actually ends up as anyway, and at least if it is Java I can use debuggers and code inspectors on it. I just don't understand what benefits XML is supposed to have - I can't think of anything that can be done in XML that couldn't be done in Java.

Posted by Alan Burlison on May 03, 2007 at 01:57 PM BST #

XML is assumed to be a language because its name says so! In order to avoid this confusion, I think XML should be called as XMD (eXtensible Markup Document). But it might be too late in the game to change the name. Just like the name 'SOAP' has nothing to do with Objects, we have to live with the 'XML' name.

Posted by daisychain on May 15, 2007 at 07:38 PM BST #

XML is wonderful for storing databases, and other sorts tree-style data storage, but I fully agree that it's not, nor should it even be looked at as if it were, a programming language. It exists for markup.

Daisychain: are you suggesting that HTML is also assumed to be a programming language? Titles are meant to be read as a whole.

Posted by Andrew Parnell on August 15, 2007 at 02:19 AM BST #

Post a Comment:

Name:
E-Mail:
URL:

Your Comment:

HTML Syntax: NOT allowed