{"id":2237,"date":"2005-11-22T18:49:00","date_gmt":"2005-11-22T18:49:00","guid":{"rendered":"https:\/\/test.simple-talk.com\/uncategorized\/wing-dings\/"},"modified":"2016-07-28T10:48:41","modified_gmt":"2016-07-28T10:48:41","slug":"wing-dings","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/blogs\/wing-dings\/","title":{"rendered":"Wing Dings"},"content":{"rendered":"<p>Occasionally when developing software you come across really absurd or bizarre bugs. The user interface for the application I&#8217;m currently developing recently exhibited one of these: a propensity for beeping periodically, for no readily explicable reason. To be precise, not so much a beeping as a &#8220;ding&#8221;ing.<\/p>\n<p> Now like most software developers, I work in an environment where workstations don&#8217;t tend to have speakers. People who do want to listen to music bring in headphones, and thus get to live in their own audio universes.<\/p>\n<p> So it was only whilst idly listening to some music whilst testing the latest shiny new feature that I suddenly noticed that my otherwise quite pleasantly heavy soundtrack was periodically letting up from its relentless drumming and so forth in order to go &#8220;ding&#8221;.<\/p>\n<p> I&#8217;ve had this with MP3s before, usually after having employed rather low quality CD ripping software (by which I don&#8217;t necessarily mean software that isn&#8217;t commonly (mis)used for that little job on many thousands of PCs around the world). But I&#8217;d played these particular MP3s many times before without unnecessary &#8220;ding&#8221;age. They were tastefully &#8220;ding&#8221; free. Distressingly, I noticed that the &#8220;dings&#8221; corresponded quite closely with my mouse activity clicking bits of our application. The evidence was beginning to pile up.<\/p>\n<p> I knew for a fact that I wasn&#8217;t advertently causing anything to go &#8220;ding&#8221; in our user interface code. So I promptly took the dutiful approach that any professional programmer would take. After careful consideration I filed a bug report, assigned it to myself, and cheerfully moved onto shinier and easier ground.<\/p>\n<p> However, since we&#8217;ve been getting close to showing off this application to the public, I&#8217;ve had to return to the land of &#8220;ding&#8221;, grumbling and rolling up my sleeves.<\/p>\n<p> I won&#8217;t bore you with tales of endlessly commenting out bits of user interface code, rerunning the application, toying with it, hearing it go &#8220;ding&#8221;, returning to my development environment (which also has a vexing habit of &#8220;ding&#8221;ing at me &#8211; and, mark you, a less soothing &#8220;ding&#8221; under the Windows default sound scheme than one exhibited by our application), rinse, repeat.<\/p>\n<p> The upshot of this worthy investigation was that the offending &#8220;ding&#8221;s were being produced by a rich text box control. As and when we had occasion to ask it to not display anything at all, if it didn&#8217;t mind, it would &#8220;ding&#8221;. Under .NET, RichTextBox.AppendText (or more precisely, the SelectionText property invoked by AppendText) will &#8220;ding&#8221; if it&#8217;s assigned an empty string. Which is exceedingly nice of it.<\/p>\n<p> This &#8220;feature&#8221; does beg one question: why? It smacks of the kind of debug code one might leave in as a control author (&#8220;hmm, might be getting empty strings, better ding to make sure people are aware of it&#8221;. But in .NET we have Exceptions for that sort of thing. There is a reason why our language doesn&#8217;t natively permit the following:<\/p>\n<p> try<br \/> {<br \/> &#160;&#160;&#160; DoSomething();<br \/> }<br \/> catch ( Exception )<br \/> {<br \/> &#160;&#160;&#160; ding;<br \/> }<\/p>\n<p> Because it would be extraordinarily and vexingly pointless, not to mention pointlessly vexing. If I did write that sort of code, I&#8217;d expect the compiler to go &#8220;ding&#8221; when I tried to compile it, at the very least.<\/p>\n<p> So I recall why, when setting up a new PC, the first thing I do is turn the system sound scheme to &#8220;quiet as the grave&#8221;: the world is full of annoying applications that go &#8220;ding&#8221; at the slightest provocation. I&#8217;m happy to say that our shiny new application is no longer one of them.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Occasionally when developing software you come across really absurd or bizarre bugs. The user interface for the application I&#8217;m currently developing recently exhibited one of these: a propensity for beeping periodically, for no readily explicable reason. To be precise, not so much a beeping as a &#8220;ding&#8221;ing. Now like most software developers, I work in&#8230;&hellip;<\/p>\n","protected":false},"author":46780,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2],"tags":[],"coauthors":[],"class_list":["post-2237","post","type-post","status-publish","format-standard","hentry","category-blogs"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/2237","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/46780"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=2237"}],"version-history":[{"count":2,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/2237\/revisions"}],"predecessor-version":[{"id":41336,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/2237\/revisions\/41336"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=2237"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=2237"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=2237"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=2237"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}