November 10, 2003
XML Best Practices
The right way to understand XML is not as a technology but as a technique. The constellation of XML standards is just a toolset, and not every XML standard is useful. The important thing is to to be able to recognize strong and weak uses of XML.
There is one overarching "why" behind XML technology: it enables an important, obvious technique, but one that is too often ignored. This "XML technique" provides an excellent framework for deciding how and when - or when not - to apply any specific XML technology.
XML is Both Human- and Machine-Readable
All the elaborate standards surrounding XML come down to one basic value:
By providing a way for a wide range of data to be exchanged directly by computers in a human-readable way, XML dramatically lowers the cost of development. For example, if something is wrong with a network of systems that exchange XML files, an ordinary developer can view or alter the actual messages easily. All it takes is an ordinary text editor.
The same qualities translate to making it easy to understand how to write programs that produce XML - starting from an example document, it is trivially easy to write a "printf" program to write out XML text. And human readability also makes it easy to write programs that consume XML - the self-describing hierarchical layout of a document shows you exactly how to traverse an XML tree data structure. There is no prequisite reading of thick standards manuals to write a simple program to process an XML document.
XML is valuable because it is a rigorous machine data format that is easy for people to understand. Do not get distracted by the hundreds of other features provided by the various XML standards. No other XML feature is as important.
How to Recognize Good XML Technique
It is not hard to recognize when good XML techniques are being used in a development effort. Here are the two things that you see:
XML is being used well when it is being used both to help both people and computers to communicate with each other.
On the other hand, it is also easy to recognize XML misuse:
That's right. Since the whole purpose of XML is to ensure that multiple people and multiple programs can work with your data, you sacrificing most of the value of XML as soon as you annoint a solitary "XML expert" programmer or a lone "XML processor" program for your XML data. Lose that one programmer, or obsolete that one system, and you will understand the costs.
Let your XML Show
Robustly interoperable, safe data exchange is all about fully visible, understandable data. It must not be confused with "encapsulation", which is the object-oriented technique for taming complexity by exposing behavior and hiding data. XML technique is exactly the opposite: it reduces complexity by showing all the data and hiding any underlying behavior.
Whereas an object-oriented programmer would say "I don't care how the data is implemented, I just care what the interface does," a data-oriented XML programmer says "I don't care what the implementation does, I just care what the data contains."
The upshot: to apply good XML technique, let your XML show.Posted by David at November 10, 2003 05:08 PM
|Copyright 2003 © David Bau. All Rights Reserved.|