{"id":15713,"date":"2009-12-10T07:00:00","date_gmt":"2009-12-10T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2009\/12\/10\/only-an-idiot-would-have-parameter-validation-and-only-an-idiot-would-not-have-it\/"},"modified":"2009-12-10T07:00:00","modified_gmt":"2009-12-10T07:00:00","slug":"only-an-idiot-would-have-parameter-validation-and-only-an-idiot-would-not-have-it","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20091210-00\/?p=15713","title":{"rendered":"Only an idiot would have parameter validation, and only an idiot would not have it"},"content":{"rendered":"<p>The great thing about parameter validation is that there are people who say that only idiots would have it, and other people who say that only idiots wouldn&#8217;t.\n Back in the old days, Windows didn&#8217;t do parameter validation. If you called a function with an invalid window handle, your application crashed. If you called a function with an invalid pointer, your application crashed. If you called a function with an invalid bitmap handle, your application crashed.\n There was a lot of crashing going on.\n These crashes manifested themselves in the infamous <i>Unrecoverable Application Error<\/i> dialog, commonly known as the UAE message.\n Windows&nbsp;3.1 added parameter validation to all of the functions in <code>KERNEL<\/code>, <code>USER<\/code>, and <code>GDI<\/code>. <a href=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2008\/05\/05\/8459022.aspx#8461433\"> If an application passed an invalid window handle, then instead of crashing, it just got an error back<\/a>.\n This change was met with derision. &#8220;Oh, I&#8217;m so impressed. You finally got around to doing something you should have been doing all along. Not doing parameter validation was a totally idiotic decision.&#8221;\n But nowadays, parameter validation is out of fashion again. If you detect an invalid parameter and return an error code, then all you&#8217;re doing is masking a latent bug in the application. <a href=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2007\/07\/16\/3885472.aspx#3908086\"> It should crash and burn with a big red fat&#8217;n&#8217;ugly blinking exception<\/a>.\n In other words, we should go back to the way things were before we added parameter validation. (Well, except that the bit fat ugly exception wasn&#8217;t red and it didn&#8217;t blink.)<\/p>\n<p> Who&#8217;s the idiot now? <\/p>\n","protected":false},"excerpt":{"rendered":"<p>The great thing about parameter validation is that there are people who say that only idiots would have it, and other people who say that only idiots wouldn&#8217;t. Back in the old days, Windows didn&#8217;t do parameter validation. If you called a function with an invalid window handle, your application crashed. If you called a [&hellip;]<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[26],"class_list":["post-15713","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-other"],"acf":[],"blog_post_summary":"<p>The great thing about parameter validation is that there are people who say that only idiots would have it, and other people who say that only idiots wouldn&#8217;t. Back in the old days, Windows didn&#8217;t do parameter validation. If you called a function with an invalid window handle, your application crashed. If you called a [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/15713","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=15713"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/15713\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=15713"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=15713"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=15713"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}