{"id":189,"date":"2017-09-06T01:42:06","date_gmt":"2017-09-06T01:42:06","guid":{"rendered":"http:\/\/freedville.com\/blog\/?p=189"},"modified":"2019-04-12T14:08:14","modified_gmt":"2019-04-12T14:08:14","slug":"book-review-effective-debugging","status":"publish","type":"post","link":"https:\/\/freedville.com\/blog\/2017\/09\/06\/book-review-effective-debugging\/","title":{"rendered":"Book Review: Effective Debugging"},"content":{"rendered":"<p>In my continuous quest for self-improvement, I just finished reading&nbsp;<a href=\"https:\/\/www.amazon.com\/gp\/product\/B01HMR617O\/\">Effective Debugging: 66 Specific Ways to Debug Software and Systems<\/a> by Diomidis Spinellis. &nbsp;Debugging is a critical and under-appreciated skill. &nbsp;Building new features into software gets most of the attention and accolades, but being able to debug software keeps it running. &nbsp;Spinellis offers a wide variety of debugging techniques as the title suggests, and there is content worth learning (or re-learning!) for a developer of any skill level.<\/p>\n<p>In this review I&#8217;d like to call out a few techniques that really stuck with me.<\/p>\n<p>Item 38: Review and Manually Execute Suspect Code. &nbsp;Many developers stare at broken code on a screen. &nbsp;Spinellis argues for the developer to engage multiple senses through using print-outs, whiteboards, multiple color of pens, and manipulating physical objects. &nbsp;This pattern has definitely helped me out of several jams. &nbsp;Something about the brain gets &#8220;unstuck&#8221; when you change frames this way &#8211; your hands may see what your eye cannot!<\/p>\n<p>Item 42: Use Unit Tests. &nbsp;Anyone who knows me knows I talk and write about unit testing ad nauseam (see <a href=\"http:\/\/freedville.com\/blog\/2016\/12\/01\/test-driven-development-with-christmas-lights\/\">here<\/a> and <a href=\"http:\/\/freedville.com\/blog\/2016\/12\/04\/cognitive-system-testing-from-a-to-z\/\">here<\/a>&nbsp;for starters). &nbsp;Please indulge me in a soapbox moment once more using Spinellis&#8217; advice. &nbsp;The perfect bug report is essentially the smallest possible unit test that recreates the problem. &nbsp;Building that test gives essential clarity into what is causing the problem and what is relevant. &nbsp;The process of building this unit test is essentially writing down (in code) the entire debugging process. &nbsp;Thus, the final unit test serves as a permanent record of your debugging efforts AND can be used to prevent future regression. &nbsp;What could be better?<\/p>\n<p>Item 43: Use Assertions. &nbsp;Similar to the unit tests advice, Spinellis advises developers to turn their assumptions into coded assertions. &nbsp;These assertions should be used to verify that any pre- and post-conditions on a block of code hold true. &nbsp;Rather than putting these assertions into comments, use formal language mechanisms to put them into code. &nbsp;An assertion can be used to force immediate failure in your software, leading you immediately to the place where the failure occurred (the &#8220;fail fast&#8221; principle in action). &nbsp;Most programming languages enable assertions to be disabled, a good option when you would rather fail gracefully than crash the application.<\/p>\n<p>Item 43: Minimize the Differences between a Working Example and the Failing Code. Many times as developers we go to Stack Overflow to get the gist of a technique we want to perform, then adapt it to our current problem. &nbsp;If our new code doesn&#8217;t work, what can we do? &nbsp;The best option is to start from a &#8220;known good&#8221; place, which is probably the Stack Overflow example verbatim. &nbsp;Running quick change\/test\/verify cycles on small updates helps quickly identify where things are going off the rails. &nbsp;Relentlessly finding a &#8220;known good&#8221; state and minimizing the differences to the current\/end state is a theme that repeats in Spinellis&#8217; text and for very good reason. &nbsp;This is probably the most important advice I would give to new developers.<\/p>\n<p>These are just my favorites from the collection of 66 techniques. As a developer, it&#8217;s likely that very little of your formal education focused on building specific debugging skills. &nbsp;Even after several years in the industry, I was surprised to see a claim of 66 actual, distinct debugging techniques. &nbsp;After finishing the book, I agree with the author that a full-featured debugging tool kit has 66 techniques or even more. &nbsp;I highly recommend this book for developers of any level.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In my continuous quest for self-improvement, I just finished reading&nbsp;Effective Debugging: 66 Specific Ways to Debug Software and Systems by Diomidis Spinellis. &nbsp;Debugging is a critical and under-appreciated skill. &nbsp;Building new features into software gets&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[11],"_links":{"self":[{"href":"https:\/\/freedville.com\/blog\/wp-json\/wp\/v2\/posts\/189"}],"collection":[{"href":"https:\/\/freedville.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/freedville.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/freedville.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/freedville.com\/blog\/wp-json\/wp\/v2\/comments?post=189"}],"version-history":[{"count":2,"href":"https:\/\/freedville.com\/blog\/wp-json\/wp\/v2\/posts\/189\/revisions"}],"predecessor-version":[{"id":414,"href":"https:\/\/freedville.com\/blog\/wp-json\/wp\/v2\/posts\/189\/revisions\/414"}],"wp:attachment":[{"href":"https:\/\/freedville.com\/blog\/wp-json\/wp\/v2\/media?parent=189"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/freedville.com\/blog\/wp-json\/wp\/v2\/categories?post=189"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/freedville.com\/blog\/wp-json\/wp\/v2\/tags?post=189"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}