{"id":58,"date":"2018-09-26T02:26:51","date_gmt":"2018-09-26T02:26:51","guid":{"rendered":"https:\/\/www.allendowney.com\/blog\/?p=58"},"modified":"2018-09-26T13:20:19","modified_gmt":"2018-09-26T13:20:19","slug":"the-six-rs-of-debugging","status":"publish","type":"post","link":"https:\/\/www.allendowney.com\/blog\/2018\/09\/26\/the-six-rs-of-debugging\/","title":{"rendered":"The six R&#8217;s of debugging"},"content":{"rendered":"<p>In Modeling and Simulation yesterday I presented my six R&#8217;s of debugging:<\/p>\n<p><strong>Read<\/strong>: You have to read the code, and read what it really says, not what you think it says.\u00a0 You have to read the documentation, read the error message, and read the Stack Overflow page that comes up when you Google the error message.<\/p>\n<p>But sometimes the bug is in your head.\u00a0 If the problem is your misunderstanding, you won&#8217;t find it by staring at the code&#8230;<\/p>\n<p><strong>Run<\/strong>: You also have to run the code, makes some changes, and run the code again.\u00a0 Sometimes when you clean up the code, and you make a change that <em>should<\/em> have no effect, and it <em>does<\/em>, that gives you a hint.<\/p>\n<p>But don&#8217;t just make random changes&#8230;<\/p>\n<p><strong>Ruminate<\/strong>: Take time to think!\u00a0 What have you changed since the last time you had a working program?\u00a0 What is the program doing wrong, and what kind of error could cause it?\u00a0 What are you assuming that might be wrong?<\/p>\n<p>Question everything, but don&#8217;t just sit in silence&#8230;<\/p>\n<p><strong>Rubber duck<\/strong>: You have to talk about it.\u00a0 Find someone who&#8217;s willing to listen and explain the problem.\u00a0 You might figure it out before they have a chance to say a word.\u00a0 In that case you don&#8217;t even need a person.\u00a0 A rubber duck will do.<\/p>\n<p>Be persistent, but not too persistent&#8230;<\/p>\n<p><strong>Rest<\/strong>: If you&#8217;ve been at it a while, take a break.\u00a0 Get away from the computer, do something else, and wait for your blood pressure to come down.\u00a0 Some of the best places to find bugs are trains, showers, and bed, just before you fall asleep.<\/p>\n<p>Finally, if you are pretty much stuck, you might have to be strategic&#8230;<\/p>\n<p><strong>Retreat<\/strong>: Get back to a previous working version and start building up the code.\u00a0 Take smaller steps this time, or take different steps.\u00a0 Spend some time building code that helps you debug, like functions that visualize your data structures.<\/p>\n<p>I hope these suggestions are helpful.\u00a0 There are six things to try, so if you are stuck on one, try another.\u00a0 Debugging can be frustrating, but it is one of the most useful skills you can develop, and it applies to almost every domain, not just software development.<\/p>\n<p>If you are good at debugging, you can do anything.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Modeling and Simulation yesterday I presented my six R&#8217;s of debugging: Read: You have to read the code, and read what it really says, not what you think it says.\u00a0 You have to read the documentation, read the error message, and read the Stack Overflow page that comes up when you Google the error message. But sometimes the bug is in your head.\u00a0 If the problem is your misunderstanding, you won&#8217;t find it by staring at the code&#8230; Run:&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"https:\/\/www.allendowney.com\/blog\/2018\/09\/26\/the-six-rs-of-debugging\/\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1],"tags":[],"class_list":["post-58","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>The six R&#039;s of debugging - Probably Overthinking It<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.allendowney.com\/blog\/2018\/09\/26\/the-six-rs-of-debugging\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"The six R&#039;s of debugging - Probably Overthinking It\" \/>\n<meta property=\"og:description\" content=\"In Modeling and Simulation yesterday I presented my six R&#8217;s of debugging: Read: You have to read the code, and read what it really says, not what you think it says.\u00a0 You have to read the documentation, read the error message, and read the Stack Overflow page that comes up when you Google the error message. But sometimes the bug is in your head.\u00a0 If the problem is your misunderstanding, you won&#8217;t find it by staring at the code&#8230; Run:... Read More Read More\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.allendowney.com\/blog\/2018\/09\/26\/the-six-rs-of-debugging\/\" \/>\n<meta property=\"og:site_name\" content=\"Probably Overthinking It\" \/>\n<meta property=\"article:published_time\" content=\"2018-09-26T02:26:51+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-09-26T13:20:19+00:00\" \/>\n<meta name=\"author\" content=\"Allen B. Downey\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@AllenDowney\" \/>\n<meta name=\"twitter:site\" content=\"@AllenDowney\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Allen B. Downey\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.allendowney.com\\\/blog\\\/2018\\\/09\\\/26\\\/the-six-rs-of-debugging\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.allendowney.com\\\/blog\\\/2018\\\/09\\\/26\\\/the-six-rs-of-debugging\\\/\"},\"author\":{\"name\":\"Allen B. Downey\",\"@id\":\"https:\\\/\\\/www.allendowney.com\\\/blog\\\/#\\\/schema\\\/person\\\/4e5bfb2e9af6c3446cb0031a7bf83207\"},\"headline\":\"The six R&#8217;s of debugging\",\"datePublished\":\"2018-09-26T02:26:51+00:00\",\"dateModified\":\"2018-09-26T13:20:19+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.allendowney.com\\\/blog\\\/2018\\\/09\\\/26\\\/the-six-rs-of-debugging\\\/\"},\"wordCount\":395,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\\\/\\\/www.allendowney.com\\\/blog\\\/#\\\/schema\\\/person\\\/4e5bfb2e9af6c3446cb0031a7bf83207\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.allendowney.com\\\/blog\\\/2018\\\/09\\\/26\\\/the-six-rs-of-debugging\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.allendowney.com\\\/blog\\\/2018\\\/09\\\/26\\\/the-six-rs-of-debugging\\\/\",\"url\":\"https:\\\/\\\/www.allendowney.com\\\/blog\\\/2018\\\/09\\\/26\\\/the-six-rs-of-debugging\\\/\",\"name\":\"The six R's of debugging - Probably Overthinking It\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.allendowney.com\\\/blog\\\/#website\"},\"datePublished\":\"2018-09-26T02:26:51+00:00\",\"dateModified\":\"2018-09-26T13:20:19+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.allendowney.com\\\/blog\\\/2018\\\/09\\\/26\\\/the-six-rs-of-debugging\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.allendowney.com\\\/blog\\\/2018\\\/09\\\/26\\\/the-six-rs-of-debugging\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.allendowney.com\\\/blog\\\/2018\\\/09\\\/26\\\/the-six-rs-of-debugging\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.allendowney.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"The six R&#8217;s of debugging\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.allendowney.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.allendowney.com\\\/blog\\\/\",\"name\":\"Probably Overthinking It\",\"description\":\"Data science, Bayesian Statistics, and other ideas\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.allendowney.com\\\/blog\\\/#\\\/schema\\\/person\\\/4e5bfb2e9af6c3446cb0031a7bf83207\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.allendowney.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.allendowney.com\\\/blog\\\/#\\\/schema\\\/person\\\/4e5bfb2e9af6c3446cb0031a7bf83207\",\"name\":\"Allen B. Downey\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.allendowney.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/03\\\/probably_logo.png\",\"url\":\"https:\\\/\\\/www.allendowney.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/03\\\/probably_logo.png\",\"contentUrl\":\"https:\\\/\\\/www.allendowney.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/03\\\/probably_logo.png\",\"width\":714,\"height\":784,\"caption\":\"Allen B. Downey\"},\"logo\":{\"@id\":\"https:\\\/\\\/www.allendowney.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/03\\\/probably_logo.png\"},\"sameAs\":[\"https:\\\/\\\/www.allendowney.com\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/allendowney\\\/\",\"https:\\\/\\\/x.com\\\/AllenDowney\",\"https:\\\/\\\/github.com\\\/AllenDowney\",\"https:\\\/\\\/bsky.app\\\/profile\\\/allendowney.bsky.social\",\"https:\\\/\\\/allendowney.github.io\\\/Portfolio\\\/\",\"https:\\\/\\\/greenteapress.com\\\/wp\\\/\"],\"url\":\"https:\\\/\\\/www.allendowney.com\\\/blog\\\/author\\\/allen-downey\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"The six R's of debugging - Probably Overthinking It","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.allendowney.com\/blog\/2018\/09\/26\/the-six-rs-of-debugging\/","og_locale":"en_US","og_type":"article","og_title":"The six R's of debugging - Probably Overthinking It","og_description":"In Modeling and Simulation yesterday I presented my six R&#8217;s of debugging: Read: You have to read the code, and read what it really says, not what you think it says.\u00a0 You have to read the documentation, read the error message, and read the Stack Overflow page that comes up when you Google the error message. But sometimes the bug is in your head.\u00a0 If the problem is your misunderstanding, you won&#8217;t find it by staring at the code&#8230; Run:... Read More Read More","og_url":"https:\/\/www.allendowney.com\/blog\/2018\/09\/26\/the-six-rs-of-debugging\/","og_site_name":"Probably Overthinking It","article_published_time":"2018-09-26T02:26:51+00:00","article_modified_time":"2018-09-26T13:20:19+00:00","author":"Allen B. Downey","twitter_card":"summary_large_image","twitter_creator":"@AllenDowney","twitter_site":"@AllenDowney","twitter_misc":{"Written by":"Allen B. Downey","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.allendowney.com\/blog\/2018\/09\/26\/the-six-rs-of-debugging\/#article","isPartOf":{"@id":"https:\/\/www.allendowney.com\/blog\/2018\/09\/26\/the-six-rs-of-debugging\/"},"author":{"name":"Allen B. Downey","@id":"https:\/\/www.allendowney.com\/blog\/#\/schema\/person\/4e5bfb2e9af6c3446cb0031a7bf83207"},"headline":"The six R&#8217;s of debugging","datePublished":"2018-09-26T02:26:51+00:00","dateModified":"2018-09-26T13:20:19+00:00","mainEntityOfPage":{"@id":"https:\/\/www.allendowney.com\/blog\/2018\/09\/26\/the-six-rs-of-debugging\/"},"wordCount":395,"commentCount":2,"publisher":{"@id":"https:\/\/www.allendowney.com\/blog\/#\/schema\/person\/4e5bfb2e9af6c3446cb0031a7bf83207"},"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.allendowney.com\/blog\/2018\/09\/26\/the-six-rs-of-debugging\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.allendowney.com\/blog\/2018\/09\/26\/the-six-rs-of-debugging\/","url":"https:\/\/www.allendowney.com\/blog\/2018\/09\/26\/the-six-rs-of-debugging\/","name":"The six R's of debugging - Probably Overthinking It","isPartOf":{"@id":"https:\/\/www.allendowney.com\/blog\/#website"},"datePublished":"2018-09-26T02:26:51+00:00","dateModified":"2018-09-26T13:20:19+00:00","breadcrumb":{"@id":"https:\/\/www.allendowney.com\/blog\/2018\/09\/26\/the-six-rs-of-debugging\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.allendowney.com\/blog\/2018\/09\/26\/the-six-rs-of-debugging\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.allendowney.com\/blog\/2018\/09\/26\/the-six-rs-of-debugging\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.allendowney.com\/blog\/"},{"@type":"ListItem","position":2,"name":"The six R&#8217;s of debugging"}]},{"@type":"WebSite","@id":"https:\/\/www.allendowney.com\/blog\/#website","url":"https:\/\/www.allendowney.com\/blog\/","name":"Probably Overthinking It","description":"Data science, Bayesian Statistics, and other ideas","publisher":{"@id":"https:\/\/www.allendowney.com\/blog\/#\/schema\/person\/4e5bfb2e9af6c3446cb0031a7bf83207"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.allendowney.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.allendowney.com\/blog\/#\/schema\/person\/4e5bfb2e9af6c3446cb0031a7bf83207","name":"Allen B. Downey","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.allendowney.com\/blog\/wp-content\/uploads\/2025\/03\/probably_logo.png","url":"https:\/\/www.allendowney.com\/blog\/wp-content\/uploads\/2025\/03\/probably_logo.png","contentUrl":"https:\/\/www.allendowney.com\/blog\/wp-content\/uploads\/2025\/03\/probably_logo.png","width":714,"height":784,"caption":"Allen B. Downey"},"logo":{"@id":"https:\/\/www.allendowney.com\/blog\/wp-content\/uploads\/2025\/03\/probably_logo.png"},"sameAs":["https:\/\/www.allendowney.com\/","https:\/\/www.linkedin.com\/in\/allendowney\/","https:\/\/x.com\/AllenDowney","https:\/\/github.com\/AllenDowney","https:\/\/bsky.app\/profile\/allendowney.bsky.social","https:\/\/allendowney.github.io\/Portfolio\/","https:\/\/greenteapress.com\/wp\/"],"url":"https:\/\/www.allendowney.com\/blog\/author\/allen-downey\/"}]}},"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.allendowney.com\/blog\/wp-json\/wp\/v2\/posts\/58","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.allendowney.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.allendowney.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.allendowney.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.allendowney.com\/blog\/wp-json\/wp\/v2\/comments?post=58"}],"version-history":[{"count":5,"href":"https:\/\/www.allendowney.com\/blog\/wp-json\/wp\/v2\/posts\/58\/revisions"}],"predecessor-version":[{"id":63,"href":"https:\/\/www.allendowney.com\/blog\/wp-json\/wp\/v2\/posts\/58\/revisions\/63"}],"wp:attachment":[{"href":"https:\/\/www.allendowney.com\/blog\/wp-json\/wp\/v2\/media?parent=58"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.allendowney.com\/blog\/wp-json\/wp\/v2\/categories?post=58"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.allendowney.com\/blog\/wp-json\/wp\/v2\/tags?post=58"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}