XML as code

Via Alistair’s cakeBlog, I found this to be a good read.

Now, I am a huge fan of XML, and have gone through [my] three phases of XML usage:

1. 1999-2000: XML everywhere. Used it for everything, list boxes, drop-down menus, you name it – all populated from SQL Server tables. It was way cool. But, half way through the project’s duration (not feature set), realisation set in, hey, it take a lot of time to work with XML if it’s everywhere. Why don’t we just use it where it’ll provide some benefits?

2. 2000-2002: Refactoring from XML everywhere to XML here and there. Anywhere data had to cross boundaries, XML has its place – combined with web services, XML was starting to take shape.

3. 2002-today: Use it wisely…for syndication/content aggregation and connected systems. Extending the crossing of boundaries to between disparate systems.

I’m still in the third phase, although I have an idea about how XML will play a part in the next [fourth] phase, I can’t reveal it here just yet. It’s just not firmed up enough to write much about it.

Naturally, whenever I hear folks ranting on about XML and how bloated it is, I’m right in there kicking off a debate! However, Allen’s Just Say No to XML article is one that I will happily agree with. XML provides us with a super means of connecting systems together. However, by virtue of the XML DOM, it provides us with a parser and a syntax checker. Couple and XML document with an XML Schema, and suddenly we can control the order of the XML elements in the XML document and control data types…we’ve kind of got ourselves a language parser. And it seems that folks have latched on to this concept and are using XML documents to convey more than data and meaning, but to carry out specific programming instructions, i.e. XML, as a mark-up language, is being used as a programming language. Except it won’t be any programming language that you or I are familiar with. It’s likely to be a hybrid of the original author’s favourite “instructions”. There will be no language constructs, such as partial classes, heck there won’t even be classes as we know them. And, in the absence of XSLT, it’s likely to be procedural in nature.

If you’re thinking of using an XML document to add some form of programmatic instructions to your application, please, don’t. Learn how to use some of the many [free] language parsers that are out there, integrate them into your application and you’ll have a much more maintainable and robust application. And it’ll probably save you a lot of time – you won’t be writing what amounts to an interpreter were you to use XML elements as instructions.

Technorati Tags: , , , , , , , , ,