{"id":44904,"date":"2015-05-08T07:00:00","date_gmt":"2015-05-08T21:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2015\/05\/08\/documentation-creates-contract-which-is-why-you-need-to-be-very-careful-what-you-document\/"},"modified":"2019-03-13T12:15:19","modified_gmt":"2019-03-13T19:15:19","slug":"20150508-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20150508-00\/?p=44904","title":{"rendered":"Documentation creates contract, which is why you need to be very careful what you document"},"content":{"rendered":"<p>A person with a rude name asks, &#8220;<a HREF=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2014\/06\/30\/10538242.aspx#10538401\">Why does MS not document the system metrics used by classic\/pre-uxtheme windows and common controls<\/a>? <a HREF=\"http:\/\/web.archive.org\/web\/20070301202835\/http:\/\/shellrevealed.com\/photos\/blog_images\/images\/4538\/original.aspx\">This image<\/a> is really useful and I wish all of this was actually documented<\/a>.&#8221; <\/p>\n<p>Actually, that picture explains why it <i>isn&#8217;t<\/i> documented. <\/p>\n<p>Suppose such a picture existed in the Windows 2000 documentation. I don&#8217;t know what it would say exactly, so suppose, for the purpose of discussion, that it said that the caption buttons are exactly <code>SM_CX&shy;FRAME<\/code> pixels from the right-hand edge of the window, and that the buttons are exactly <code>SM_CX&shy;SIZE<\/code> pixels wide, with exactly <code>SM_CX&shy;EDGE<\/code> pixels of padding between the buttons, and the buttons are exactly <code>SM_CY&shy;SIZE<\/code> pixels tall, with  <code>SM_CY&shy;EDGE<\/code> pixels between the top of the button and the top of the window. <\/p>\n<p>Once that picture existed in the documentation, the picture you linked to could never exist. <\/p>\n<p>The picture from Windows 2000 doesn&#8217;t include the <code>SM_CX&shy;PADDED&shy;BORDER<\/code> or the the <code>SM_CY&shy;PADDED&shy;BORDER<\/code>. It can&#8217;t, because those metrics didn&#8217;t exist in Windows 2000. Since the diagram is part of the documentation, it is contractual, and it would not be possible to alter the layout of the window caption (say, by incorporating a new metric like <code>SM_CX&shy;PADDED&shy;BORDER<\/code>), because that would break existing code. <\/p>\n<p>For example, a program may have looked at the diagram and concluded, &#8220;Okay, so if I want to programmatically click the Close button, I can go to the upper right corner of the window, move down <code>SM_CY&shy;FRAME + 1<\/code> pixels, move left move down <code>SM_CX&shy;FRAME + 1<\/code> pixels, and click there, and it will hit the button.&#8221; <\/p>\n<p>And then Windows Vista shows up, adds some <code>SM_CX&shy;PADDED&shy;BORDER<\/code> between the Close button and the right edge, and the program stops working. <\/p>\n<p>Publishing the <a HREF=\"http:\/\/blogs.msdn.com\/b\/oldnewthing\/archive\/2014\/12\/02\/10577260.aspx\">redlines<\/a> would force the visual layout to be locked in stone. Windows&nbsp;95 could not have added the Close button. Windows Vista could not have added extra padding around the buttons. <\/p>\n<p>Note that changing the visual layout of the caption does not break programs which draw their own caption bar. They will continue to draw the caption bar their own custom way. If they tried to mimic the Windows&nbsp;2000 caption bar, then they will continue to mimic the Windows&nbsp;2000 caption bar, even on Windows Vista. But nobody gets hurt, because the application is doing both the drawing and the hit-testing, so it remains in sync with itself. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Once it&#8217;s documented, it needs to remain supported forever.<\/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-44904","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-other"],"acf":[],"blog_post_summary":"<p>Once it&#8217;s documented, it needs to remain supported forever.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/44904","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=44904"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/44904\/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=44904"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=44904"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=44904"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}