XML Configs Suck
While XML is a great format for structured data, its not ideal for configuring code frameworks. When working with a framework your code is often broken up into smaller segments that are coordinated at run time. All to often this coordination is wired together using XML configuration files. Its this separation of configuration from code that makes XML so sucky. Embedding metadata into the code itself seems like a much more natural way to manage complex configuration.
Imagine there's no code, just metadata captured through the use of cfproperty. In fact, all the metadata you might need to describe exactly how the component should be persisted in the database, its relationship to other components, the behaviour of its form elements when editing, the periodicity for caching its views, and even enough rudimentary information to display information to users.
In the FarCry Core web application framework you might describe a super hero with a few properties. Name and type are enough basic information for the framework to understand how to persist the data model in the database (mySQL, MSSQL, Postgres and Oracle supported) and even provide rudimentary edit handlers.
<!--- ./packages/types/superHero.cfc --->
<cfcomponent name="superhero" extends="farcry.core.packages.types.types" output="false" displayname="Super Hero">
<cfproperty name="title" type="string" default="" hint="Super hero title." />
<cfproperty name="secrethideout" type="string" hint="The secret hideout location of the super hero" />
<cfproperty name="teaser" type="longchar" default="" hint="Mini intro for super hero biography." />
<cfproperty name="biography" type="longchar" default="" hint="Super hero biography." />
<cfproperty name="imgHero" type="string" hint="The image of the hero" />
</cfcomponent>
But the fun really starts when you play with the extensive "formtool" library; look out for the attributes with the ft prefix. Just by nominating metadata you can start to generate very rich edit handlers all without a single line of code. Of course if you need to get your hands dirty you can build your handlers from scratch or leverage just parts of the formtool engine as needed.
<cfcomponent ...>
<cfproperty ftSeq="1" ftFieldset="General Details" name="title" type="string" default="" ftLabel="Title" hint="Super hero title." />
<cfproperty ftSeq="2" ftFieldset="General Details" name="secrethideout" type="string" ftLabel="Secret Hideout" hint="The secret hideout location of the super hero" />
<cfproperty ftSeq="3" ftFieldset="General Details" name="teaser" type="longchar" default="" ftLabel="Teaser" hint="Mini intro for super hero biography." />
<cfproperty ftSeq="4" ftFieldset="General Details" name="biography" type="longchar" default="" ftLabel="Biography" ftType="richtext" hint="Super hero biography." />
<cfproperty ftSeq="10" ftFieldset="Imagery" name="imgHero" type="string" ftType="image" ftLabel="Hero Image" ftDestination="/superhero/imgHero" ftImageWidth="120" ftImageHeight="120" ftAutoGenerateType="fitInside" hint="The source image to upload" />
</cfcomponent>
FarCry even handles one to many and many to many relationships through metadata. Adding an array type and nominating the objects it can join to updates the model and provides comprehensive library ui tools for editing the relationship.
<cfcomponent ..>
...
<cfproperty ftSeq="12" ftFieldset="Related Content" ftWizardStep="Relationships"
name="apowers"
type="array"
ftLabel="Powers"
ftJoin="superPower"
hint="Array of superhuman powers." />
...
</cfcomponent>
The metadata kind of tells story right there in the code to both the developer and the framework. It's much more intuitive than trying to capture the same information in a separate XML file. Its just one of the reasons I love working with a framework like FarCry Core.

Comments
rob on 15 Aug 2008 04:47 AM
One of the benefits of using XML as a config format is you can generate the config from some other processes (like a deploy script, or XSLT, or what have you). Since CF is really close to XML, the benefit of using XML for that purpose is almost pointless IMHO (unless you want the same config file for different types of systems - and even then I think there are better options). I've become less and less a fan of XML over the years for similar reasons to yours.
Steve Bryant on 15 Aug 2008 12:32 PM
For all that you say XML sucks, the code you show really looks like XML. I know, I know it is technically CFML but it is still basically XML.
Geoff Bowers on 15 Aug 2008 01:03 PM
My beef is not really with XML itself. Its the notion of a single all powerful wiring config i don't like. In FarCry, the config for a specific content type is contained in the component itself, rather than various disparate areas of the code base being configured from a central wiring point. But heh XML configs are useful -- I just like having the config "nearer" the relevant object.
Steve Bryant on 15 Aug 2008 09:40 PM
I agree with you there. I use XML, but I try to keep it in the thing being configured. So, I have XML in my CFCs as well. Really a very similar idea to what you are doing - just different syntax.
den on 17 Sep 2008 07:41 AM
I did something similar for "annotating" cfcs for use with hibernate. pretty cool!