Lists Home |
Date Index |
On Mon, 16 Dec 2002 16:15:34 +0000, Miles Sabin <email@example.com> wrote:
> I think there's a slightly different lesson to learn from Sean's experience.
> Partly it's just that a lot of APIs are badly designed ... in a lot of
> cases that's because the designers don't really understand what's going
> on in the system (having seen the inner workings of rather too many HTTP
> client libraries I'm sadly convinced that's all too often the case).
I think I agree. (I think we've had this discussion about Sean's article
before, sorry if I'm repeating, or contradicting :-) myself):
This all goes back to OOP 101 - an API allows one to manipulate an "object"
without knowing its internal representation, i.e., the principle of
encapsulation. But an API is only as good as the abstraction of the class
of objects that it embodies. Perhaps the other HTTP APIs represented bad
abstractions of what's actually going on ... and ultimately became more
trouble than they were worth, at least to a skilled programming needing
non-trivial access to the protocol features.
But especially with committee-written standards (and I think this reflects
the points in Daniel Veillard's post) there may simply be no coherent
abstraction that can be cleanly encapsulated. I don't know enough about
HTTP to have an opinion if the APIs are merely bad, or if they reflect an
unpleasant reality about the conceptual integrity of the underlying
protocol. (I would tend toward the former). But with XML, having spent
quite a bit more of my life that I will probably care to admit on Judgement
Day working on APIs for it, I think it's hard to argue that there is a
clean abstraction that can be exposed with APIs and implementations can be
hidden behind. Sheesh, we can't even agree if XML has a "data model" at
all, much less on whether namespace URIs are associated with each node in
their scope or only with the scope itself. Thus, some questions are
unanswerable, such as "what happens when I move a node from one namespace
scope to another"? Does it bring its namespace URI along with it, or does
it get the one in the new scope?
As a practical matter, "edit the syntax to make it look like you want, then
re-parse" is the most reliable way to avoid such messes. As a Best Practice
guideline, Sean's advice is right on. But I think this is more of a
symptom of XML's need for some serious refactoring and cleanup rather than
a reflection of a deep truth about APIs per se.
[Heigh ho, heigh ho, to the "does XML suck" permathread we go ...]