{"id":36,"date":"2006-12-13T02:10:58","date_gmt":"2006-12-13T06:10:58","guid":{"rendered":"http:\/\/www.coactus.com\/blog\/?p=36"},"modified":"2007-04-11T07:59:35","modified_gmt":"2007-04-11T11:59:35","slug":"validation-considered-harmful","status":"publish","type":"post","link":"http:\/\/www.coactus.com\/blog\/2006\/12\/validation-considered-harmful\/","title":{"rendered":"Validation considered harmful"},"content":{"rendered":"<p>We don&#8217;t get a lot of enjoyment about trampling sacred cows here at Coactus, honest we don&#8217;t.  But we see so much bad practice out there &#8211; <a href=\"http:\/\/www.infoq.com\/articles\/separation-of-concerns\">more so recently<\/a> &#8211; that we feel compelled to speak out.<\/p>\n<p>Today&#8217;s sacred cow is document validation, such as is performed by technologies such as <a href=\"http:\/\/en.wikipedia.org\/wiki\/Document_Type_Definition\">DTD<\/a>s, and more recently <a href=\"http:\/\/www.w3.org\/TR\/xmlschema-1\/\">XML Schema<\/a> and <a href=\"http:\/\/www.relaxng.org\">RelaxNG<\/a>.<\/p>\n<p>Surprisingly though, we&#8217;re not picking on any one particular validation technology.  XML Schema has been getting its fair share of <a href=\"http:\/\/cafe.elharo.com\/xml\/relax-wins\/\">bad press<\/a>, and rightly so, but for different reasons than we&#8217;re going to talk about here.  We believe that virtually <em>all<\/em> forms of validation, as commonly practiced, are harmful; an anathema to use at Web scale.  Specifically, our argument is this;<\/p>\n<blockquote><p>\nTests of validity which are a function of time make the independent evolution of software problematic.\n<\/p><\/blockquote>\n<p>Why?  Consider the scenario of two parties on the Web which want to exchange a certain kind of document.  Party A has an expensive support contract with BigDocCo that ensures that they&#8217;re always running the latest-and-greatest document processing software.  But party B doesn&#8217;t, and so typically lags a few months behind.  During one of those lags, a new version of the schema is released which relaxes an earlier stanza in the schema which constrained a certain field to the values &#8220;1&#8221;, &#8220;2&#8221;, or &#8220;3&#8221;; &#8220;4&#8221; is now a valid value.  So, party A, with its new software, happily fires off a document to B as it often does, but this document includes the value &#8220;4&#8221; in that field.  What happens?  Of course B rejects it; it&#8217;s an invalid document, and an alert is raised with the human adminstrator, dramatically increasing the cost of document exchange.  All because evolvability wasn&#8217;t baked in, because a schema was used in its default mode of operation; to restrict rather than permit.<\/p>\n<p>Just because it only makes sense for a field in a document to contain the values &#8220;1&#8221;, &#8220;2&#8221;, or &#8220;3&#8221; today, does not necessarily mean &#8220;4&#8221;, &#8220;0&#8221;, or &#8220;9834&#8221; won&#8217;t be valid tomorrow.  Similarly, just because a document doesn&#8217;t now contain a field named &#8220;Blarg&#8221;, it doesn&#8217;t mean it won&#8217;t later.  A good rule of thumb in document design is to avoid making assumptions about what <em>won&#8217;t<\/em> be there in the future, and a rule of thumb for software is to defer checking extension fields or values until you can&#8217;t any longer.<\/p>\n<p>On the Web, you need to be able to process messages from the future.<\/p>\n<p>P.S. if you&#8217;re wondering what time-<em>in<\/em>dependent validity looks like, we&#8217;ll cover that at a later date (check the tags of this post for a hint).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We don&#8217;t get a lot of enjoyment about trampling sacred cows here at Coactus, honest we don&#8217;t. But we see so much bad practice out there &#8211; more so recently &#8211; that we feel compelled to speak out. Today&#8217;s sacred cow is document validation, such as is performed by technologies such as DTDs, and more [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,3],"tags":[],"_links":{"self":[{"href":"http:\/\/www.coactus.com\/blog\/wp-json\/wp\/v2\/posts\/36"}],"collection":[{"href":"http:\/\/www.coactus.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.coactus.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.coactus.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.coactus.com\/blog\/wp-json\/wp\/v2\/comments?post=36"}],"version-history":[{"count":0,"href":"http:\/\/www.coactus.com\/blog\/wp-json\/wp\/v2\/posts\/36\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.coactus.com\/blog\/wp-json\/wp\/v2\/media?parent=36"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.coactus.com\/blog\/wp-json\/wp\/v2\/categories?post=36"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.coactus.com\/blog\/wp-json\/wp\/v2\/tags?post=36"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}