{"id":9158,"date":"2016-08-17T06:57:31","date_gmt":"2016-08-17T11:57:31","guid":{"rendered":"http:\/\/brucegarrett.com\/brucelog\/?p=9158"},"modified":"2016-08-17T07:10:05","modified_gmt":"2016-08-17T12:10:05","slug":"oh-microsoft-how-i-love-your-pretty-little-lies","status":"publish","type":"post","link":"https:\/\/brucegarrett.com\/brucelog\/9158","title":{"rendered":"Oh Microsoft&#8230;How I Love Your Pretty Little Lies&#8230;"},"content":{"rendered":"<p>Mostly, I do business software. That may seem surprising since I work for the Space Telescope Science Institute and we not only operate Hubble for NASA but we&#8217;re also working on the James Webb Space Telescope, which is the project I&#8217;m deeply involved in at the moment. So you might think the work I do here is all sciencey and stuff and it mostly is, but not in the flight engineering sense of it. I do business software, and science like everything else has to account for its money \u00a0and \u00a0time. So \u00a0as it turns out, a lot of my work still revolves around Microsoft products, and doing traditional business client-database applications.  \u00a0The other day I was tweaking something I&#8217;d done in Excel VBA (Visual Basic for Applications&#8230;a product Microsoft hasn&#8217;t upgraded in decades, probably because there is so much legacy stuff out there in their business user base). It was your basic fetch some data from a backend database server and feed it to Excel and let Excel make tables and charts out of it for management to ponder. And I \u00a0needed to do something that I figured I could use a custom document property for. Which I could, but not exactly in the way Microsoft&#8217;s documentation said I could.<\/p>\n<p>You run into this phenomena quickly in this trade:  \u00a0The Documentation Lies. Or more charitably, it is out of date. The documentation is buggy. The documentation is written by people who write software and hate writing documentation. If religious fundamentalists had to actually use passages in the bible like we software developers have to use the documentation and example code snippets we&#8217;re provided with maybe they&#8217;d stop waving that thing at everyone, and try a little figuring things out for themselves like we&#8217;re always doing&#8230;desperately at times. <em>Oh you&#8217;re worried about the second coming are \u00a0you? Let me show \u00a0you my \u00a0project&#8217;s \u00a0Gantt chart&#8230;<\/em><\/p>\n<p>See&#8230;I hate using Magic Numbers&#8230;<\/p>\n<blockquote>\n<p><em>In programming, a &#8220;magic number&#8221; is a value that should be given a symbolic name, but was instead slipped into the code as a literal, usually in more than one place.<\/em><\/p>\n<\/blockquote>\n<p>It makes the code hard to understand, which makes it hard to maintain. This is something a programmer is wise to avoid, even if it&#8217;s code you are nearly certain only \u00a0you will be maintaining. Time passes, the universe expands, and you open a code file you haven&#8217;t touched in years to make a small change and you&#8217;ve forgotten what ThisWorkSheet.CustomProperties.Item(1).Value referred to.  \u00a0Better to write it \u00a0ThisWorkSheet.CustomProperties.Item(&#8220;GetsGraph&#8221;).Value. And lo and behold the documentation says I can call that property with either a \u00a0numeric \u00a0value (the property index) or a string value (the property name). But it does not actually work that way.<\/p>\n<p>Let it be said Microsoft is hardly the only culprit here. My first experience with this sort of thing happened right at the starting gate of my career as a software developer \u00a0many many moons ago, when I was a youngster doing volunteer work for a gay BBS system (before the Internet Tubes came along) and I was asked to write a system for a local gay activists organization to generate welcome letters and membership funding letters and mailouts and so forth. They had a licensed copy of Ashton-Tate&#8217;s dBase IV which back then was the powerhouse database system for PCs. It was working my way through \u00a0the dBase documentation while trying out their code snippets I \u00a0had the displeasure of finding out that computer documentation will lie \u00a0though its teeth at you and laugh at your pain and suffering. In those days I hurled many a programming book across the room. Nowadays I glance at the time and do a quick rough calculation of how many minutes until Happy Hour. \u00a0<\/p>\n<p>So I got through my little difficulty the other day by creating a sensibly named numeric constant that I can pass in lieu of actually passing the value of the name of the custom property whose value I want to check. That&#8217;s what we call in the business a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Kludge\">kludge<\/a>, because I&#8217;m not certain \u00a0the property I want will have that index value Every Time. I think it&#8217;s likely since I&#8217;m the only one maintaining this code, for now, and I only have that one custom property in there. But what happens when someone else gets into this code? Okay&#8230;I&#8217;ve commented my useage of the property. But maybe the next update to Excel changes the starting index from 1 to 0? <em>Surprise!<\/em> \u00a0<\/p>\n<p>Oh well. So I get things working to a close approximation of my satisfaction. Then I sit back and I ponder the Five Stages of Software Development&#8230;<\/p>\n<blockquote>\n<p><strong>Denial<\/strong>: Oh I probably just forgot to close a parenthesis somewhere.<\/p>\n<p><strong>Anger<\/strong>: Oh F*ck Me&#8230;that is a COMPLETELY LEGAL FUNCTION CALL!!!<\/p>\n<p><strong>Bargaining<\/strong>: Maybe if I use single quotes instead of double quotes&#8230;<\/p>\n<p><strong>Depression<\/strong>: I should have gone to art school&#8230;<\/p>\n<p><strong>Acceptance<\/strong>: My software tools are buggy, the vendor is shady, the next upgrade cycle will probably depreciate my entire code base, but the bar at Rocket To Venus is open late.<\/p>\n<\/blockquote>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Mostly, I do business software. That may seem surprising since I work for the Space Telescope Science Institute and we not only operate Hubble for NASA but we&#8217;re also working on the James Webb Space Telescope, which is the project I&#8217;m deeply involved in at the moment. So you might think the work I do [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[109,95,112],"class_list":["post-9158","post","type-post","status-publish","format-standard","hentry","category-life","tag-department-of-random-complaining","tag-schrodingers-bag-o-laughs","tag-the-geek-chronicles"],"_links":{"self":[{"href":"https:\/\/brucegarrett.com\/brucelog\/wp-json\/wp\/v2\/posts\/9158","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/brucegarrett.com\/brucelog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/brucegarrett.com\/brucelog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/brucegarrett.com\/brucelog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/brucegarrett.com\/brucelog\/wp-json\/wp\/v2\/comments?post=9158"}],"version-history":[{"count":0,"href":"https:\/\/brucegarrett.com\/brucelog\/wp-json\/wp\/v2\/posts\/9158\/revisions"}],"wp:attachment":[{"href":"https:\/\/brucegarrett.com\/brucelog\/wp-json\/wp\/v2\/media?parent=9158"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/brucegarrett.com\/brucelog\/wp-json\/wp\/v2\/categories?post=9158"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/brucegarrett.com\/brucelog\/wp-json\/wp\/v2\/tags?post=9158"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}