[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: The Airplane Example (was Re: StreamingXML)

  • To: xml-dev@l...
  • Subject: RE: The Airplane Example (was Re: StreamingXML)
  • From: Uche Ogbuji <uche.ogbuji@f...>
  • Date: Wed, 05 Jan 2005 08:47:39 -0700
  • In-reply-to: <E1Cm8JK-0006b1-00@u...>
  • Organization: Fourthought, Inc.
  • References: <E1Cm8JK-0006b1-00@u...>

backtracking code
On Wed, 2005-01-05 at 10:22 +0000, Michael Kay wrote:
> > I don't
> > think I can recall having *ever* had a program fail because someone
> > passed a float to a routine that expected an int.  Most errors by most
> > competent programmers (IMO) are of much sterner stuff.
> Someone found a bug in my knight's tour stylesheet three years after it was
> first written. I had never managed to find any input conditions that tested
> the backtracking code, in fact I speculated that the condition could never
> occur. But it did, and the backtracking code was wrong, and the error was
> caught by virtue of the fact that the parameters to a function were being
> passed in the wrong order: f(x,y) instead of f(y,x). 
> (The bug was actually found in the XSLT 2.0 version of the code, to which I
> had added type declarations, which Saxon at that time was only checking
> dynamically. XSLT 1.0 would have carried on to produce incorrect output; the
> current version of Saxon would have detected the error at compile time.)
> So type-checking proved useful here, and static type-checking would have
> been even more useful. But only because the two arguments to the function
> happened to be of different types.

The knight's tour example is very interesting.  Thanks.  I am unclear on
one thing, though.  You say:

"But it did, and the backtracking code was wrong, and the error was
caught by virtue of the fact that the parameters to a function were
being passed in the wrong order: f(x,y) instead of f(y,x). "

So there were two errors there?  The order-of-execution error and the
error in the backtracking bug?  If so, do you consider the backtracking
bug also a type-related error that Saxon/XSLT 2.0 would have caught?

And finally, are you sure the error sources were not really a matter of
function preconditions (which I do support), and were only approximated
by argument typing?

Finally, as I recall the knight's tour XSLT, a lot of the params are
integers.  Would you say the argument transposition error was
fortuitously one where different WXS types *could* be asserted, and that
static typing would have been no help if 2 integer values had been
transposed (i.e. value error)?

I would guess that a precondition may have had more reach (in terms of
safety) in such a case.

Of course most unit testing today is just a matter of pre-conditions,
post-conditions and invariants tested outside the original source code,
because of lack of support for such assertions in most languages (and
because of the inadequancy of mere type checking for ensuring

> I think it's very typical of real-life software that exception paths don't
> get adequately tested. In fact, it can be almost impossible to test them. We
> found, for example, that it's impossible to simulate a disc failure
> accurately enough to see how database software will respond to it. The same
> is almost certainly true of aircraft engine failures.

Good point, especially re: my surprise that redundancy didn't save
Ariane, but again I'd say such catastrophic failures are beyond the
reach of most techniques, including static type checking.

Uche Ogbuji                                    Fourthought, Inc.
http://uche.ogbuji.net    http://4Suite.org    http://fourthought.com
Use CSS to display XML - http://www.ibm.com/developerworks/edu/x-dw-x-xmlcss-i.html
Full XML Indexes with Gnosis - http://www.xml.com/pub/a/2004/12/08/py-xml.html
Be humble, not imperial (in design) - http://www.adtmag.com/article.asp?id=10286
UBL 1.0 - http://www-106.ibm.com/developerworks/xml/library/x-think28.html
Use Universal Feed Parser to tame RSS - http://www.ibm.com/developerworks/xml/library/x-tipufp.html
Default and error handling in XSLT lookup tables - http://www.ibm.com/developerworks/xml/library/x-tiplook.html
A survey of XML standards - http://www-106.ibm.com/developerworks/xml/library/x-stand4/
The State of Python-XML in 2004 - http://www.xml.com/pub/a/2004/10/13/py-xml.html


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.

Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.