{"id":51,"date":"2003-09-22T19:35:50","date_gmt":"2003-09-22T18:35:50","guid":{"rendered":"http:\/\/www.nobugs.org\/blog\/archives\/2003\/09\/22\/the-exceptional-mr-gosling\/"},"modified":"2003-09-22T19:35:50","modified_gmt":"2003-09-22T18:35:50","slug":"the-exceptional-mr-gosling","status":"publish","type":"post","link":"https:\/\/www.nobugs.org\/blog\/archives\/2003\/09\/22\/the-exceptional-mr-gosling\/","title":{"rendered":"The Exceptional Mr Gosling"},"content":{"rendered":"<p>James Gosling <a href=\"http:\/\/www.artima.com\/intv\/solid.html\">talks to artima.com<\/a> about exceptions and how they&#8217;re used in the real world.<\/p>\n<p>The discussion about the &#8220;one true path&#8221; strike a chord with me.  I spend several years working on a networked medical application.  When you&#8217;re talking to a network then anything can happen.  The network goes silent.  You get the wrong kind of packet.  The network layer gives an error.  You receive a data packet containing bad data (like, &#8220;length of next data item = 0xffffffff bytes&#8221;).  The machine you&#8217;re talking to rudely drops the connection rather than terminating gracefully.  These aren&#8217;t theoretical problems &#8212; they occur regularly in the field.  And if you don&#8217;t handle each and every one of them correctly, you&#8217;ll get annoyed customer phoning you up and you spend your weekend fixing bugs instead of having fun.<\/p>\n<p>And if you think you&#8217;re safe because you&#8217;re not talking to a network, how does your application cope when the users disk gets full?  Every single write to a file can potentially fail.<\/p>\n<p>So, I think the whole notion of the &#8220;one true path&#8221; is a seductive fallacy.  It&#8217;s seductive becuase the &#8220;one true path&#8221; is where all the cool stuff happens. Coders love making computers do cool stuff.  In constrast, handling all the exceptions and return values is dull &#8211; it&#8217;s is a bit like &#8220;dotting the i&#8217;s and crossing the t&#8217;s&#8221;.  Who cares if your application bombs when the user&#8217;s disk is full?  Well, the user sure will.<\/p>\n<p>But when you are a grown-up programmer then you don&#8217;t get to <i>just<\/i> do the cool stuff.  All of those &#8220;error conditions&#8221; are first-class code routes, just like the &#8220;one true path&#8221; and some day Real Soon Now a customer is going to run down one of them.<\/p>\n<p>Here&#8217;s a fun idea:  Before you ship your next product, run your test plan on an instrumented build and record code coverage information.  Then in your shipped product, detect when an end-user starts running down a codepath which wasn&#8217;t touched by your testing and then pop up a big alert box saying &#8220;Warning:  You are the first person to ever run this bit of code!!&#8221;.  I&#8217;d love to hear of a company which dares to do this.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>James Gosling talks to artima.com about exceptions and how they&#8217;re used in the real world. The discussion about the &#8220;one true path&#8221; strike a chord with me. I spend several years working on a networked medical application. When you&#8217;re talking to a network then anything can happen. The network goes silent. You get the wrong [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-51","post","type-post","status-publish","format-standard","hentry","category-programming"],"_links":{"self":[{"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/posts\/51","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/comments?post=51"}],"version-history":[{"count":0,"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/posts\/51\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/media?parent=51"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/categories?post=51"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/tags?post=51"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}