Hi Folks, Yesterday Michael Kay made a fascinating statement: I would expect that for most documents …
Ah, to assess a statement it is important to be able to measure (quantify) the statement.
Let’s take an example … I would like to create an XML Schema that conforms to a list of principles. One of the principles is this: Design the schema so it can be easily changed How to quantify: “can be easily changed when requirements change”?
Assertion: If we cannot quantify how easy it is to change a schema, then the principle is meaningless. Or, flip it around: if we cannot quantify how resistant a schema is to change, then the principle is meaningless. Do you agree? Let’s see if we can identify a couple schema features that make changes hard. Consider a schema that uses a large inheritance tree (derive-by-extension and/or derive-by restriction). A change to complexType ABC impacts every complexType under ABC. If a requirement change applies only to ABC and not to any of its
descendants (or applies to a subset of its descendants), then the schema is resistant to changes. Assertion: Inheritance trees are evil. They create schemas that are resistant to changes. The deeper the inheritance tree, the more brittle the schema. Want schemas that are easily changed when requirements change? Then don’t use inheritance
trees. Do you agree? Next, consider a schema that declares an element XYZ to be mandatory (minOccurs="1"). If a requirement change says XYZ is optional, then XML instances that conform to the previous schema are suddenly invalid.
Assertion: Mandatory elements are evil. They create schemas that are resistant to changes. Want schemas that are easily changed when requirements change? Then don’t make elements mandatory. Do you agree? How to quantify these things? Start at a score of zero. For every complexType that is part of an inheritance tree, add minus one (-1). For every element that is declared to be mandatory, add minus one (-1).
Well, something along those lines. What other things make an XML Schema hard to change? /Roger |