XML and OO (where's the wires ?)
Fri, Jul 21 2006 12:27
I was just reading Ralf's post about some future directions for XML
and one thing that struck me is there is still a mismatch between "Data" and "OO". XML is really just descriptive data, at least it is at present. Of course it doesn't have to be, it could just as easily include event wire up, just as we seeing extended forms of XML such as xaml or html.
So as far as languages go, I think that ability to wire is probably the next hurdle if we want to treat XML as objects. But because we'd be attaching the wires, it could lead to some really nice possibilities
(warning, I'm thinking out loud here, and haven't sat down to consider this in detail yet <g>)
Let's take a simple example of Customer who has an Address. Presume the XML is something like <Customer id="1234"><Address>….</></>
Now even if we treat XML as a first class citizen in the languages, how do we say I want an event to fire when Address changes, or I want to validate Address first when changed. We could have simple schema based validation, but sometimes we need more than that. For example I might want to search via a service to ensure such address really exists. At a simpler level, I might just want the UI to be updated when there is such a change.
To achieve any of that today, we'd have to define our OO model and move the data into it. that is the XML alone can't take us there. So we don't see XML as a true first class citizen, rather it's just the "Data", not the "behavior" . If however we allowed the merging of delegates, anonymous delegates, partial classes, and attribute based behaviors, we could actually have something as powerful as OO, yet more flexible.
For example, I could like xaml or jscript, do wire up to a delegate, including anonymous delegates and lambda expressions to the Address element. It would be nice if I could also apply a partial class to the Customer element, that included overrides (perhaps implicit override) for the Address property.
It's also be nice if I could just say "Attach rich events" somehow declaratively to the whole Customer element, and in effect you'd have all the richness of IBindingList, without the use of proxies or moving the xml out of the xml into OO.