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

Re: It is okay for things to break in the future!

  • From: Norman Gray <norman.gray@glasgow.ac.uk>
  • To: Michael Kay <mike@saxonica.com>
  • Date: Mon, 05 Sep 2022 17:22:04 +0100

Re:  It is okay for things to break in the future!
Michael and all, hello.

On 4 Sep 2022, at 20:58, Michael Kay wrote:

> So you're seriously suggesting that just because no employee has ever earned a bonus of more than $1m, or has had a surname longer than 20 characters, your schema should impose these as upper limits?

I don't think that is what Roger -- or John Carnack in the remark Roger originally quoted -- is saying.  The discussion has drifted towards validation and away from the original rather interesting point about design, and limits.

To stick with the telephone number example (though I'm not sure it's the best one), you _could_ design a system which would deal with arbitrary-length phone numbers, but it would be more complicated than one which presumed all numbers had 12 digits, or which normalised input to 12 digits.  You'd be more likely to get the more general version wrong, it wouldn't be tested as thoroughly, and it wouldn't have any payoff, because you would expect to interoperate with other systems that presumed only 12 digits.  Thus, as a matter of engineering good taste, you might well decide against the generalised behaviour, and to hard-code 12 telephone digits in your system.

Such a decision is also reasonable because there's a standard which governs this, and if we ever get direct dial telephony to Mars, and the phone numbers get longer, we know that we'll be in for a couple of decades of software rewrites anyway.  So it's not an offence against engineering aesthetics to hard-code the string length.

In this context, the role of schema validation is to push this assumption as far forward in the input chain as possible (and you can do this validation well or very badly).  But the interesting thing here is not the validation -- where, when, how, or anything like that -- but the justification for the hard-coding.  The relevance of this example is simply, I think, to indicate that it can be justifiable _not_ to take an opportunity to be general, even if it's easy in a particular case.

Carnack's point, as I read it, was that there can be a value in deliberately not removing a software limit, or assumption, even when doing so appears to be 'free'.  If you hard-code a limit -- such as an array size -- with a limit which is an order of magnitude larger than anything you expect to see in practice, but you do encounter a situation where that limit is reached, then you do unequivocally want to know that, since a core assumption about the program is wrong.  He's saying, in other words, that this is (a softer version of) a code assertion: if the assertion fails, then the thing that can't happen has happened, the program has _already_ failed in some way, and you want the world to stop at this point.  That is, 'breaking' at this point in the future might be the right thing to do.

I"m not sure I 100% agree with Carmack here, but the point 'limits are a type of assertion' is not one I've come across before, and I think it's an interesting one.

(To be clear, I don't think that assert(n < ARRAY_SIZE) would be a good way to express this, because I believe assert() assertions should be invariants you believe to be mathematically/logically true about your program.  But if(n >= ARRAY_SIZE) fail_noisily("the world is upside down"); is legitimate and would have much the same effect).

>  You don't know what will happen in the future, but that doesn't entitle you to impose artificial restrictions to prevent it happening.

You don't know what will happen, but it may be prudent to guess what will happen _rather than_ trying to cope with anything that might happen, and if you do that, you may want to learn you're wrong very unambiguously.

Best wishes,

Norman


-- 
Norman Gray  :  https://nxg.me.uk
SUPA School of Physics and Astronomy, University of Glasgow, UK


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.