{"id":21982,"date":"2017-02-06T10:00:30","date_gmt":"2017-02-06T15:00:30","guid":{"rendered":"https:\/\/simpleprogrammer.com\/?p=21982"},"modified":"2023-02-12T01:20:56","modified_gmt":"2023-02-12T06:20:56","slug":"effective-debugging","status":"publish","type":"post","link":"https:\/\/simpleprogrammer.com\/effective-debugging\/","title":{"rendered":"A Programmer&#8217;s Guide To Effective Debugging"},"content":{"rendered":"<p>As a software developer, I can guarantee you one thing for sure: <strong>you are going to spend a great deal of time debugging code.<\/strong>\\n\\nThere are certain constants in life which are unavoidable: death, taxes, and programmers creating bugs.\\n\\nSince so much of your time will be spent debugging code, it\u2019s probably <a href=\"https:\/\/simpleprogrammer.com\/technical-skills-software-developer\/\">a good idea for a developer to be good<\/a> at debugging, don\u2019t ya think?\\n\\nUnfortunately, many developers\u2014even highly experienced ones\u2014tend to, well\u2026 suck.\\n\\nThere are plenty of developers who can whip through new features and sling code around like nobody\u2019s business, but <strong>who cleans up the mess of bugs they leave behind?<\/strong>\\n\\nIt\u2019s one thing to know how to write good code; it\u2019s another thing to know how to debug the ugliest code you\u2019ve ever seen in your life that was written by the legendary Bob who built the whole first version of the application in 48 hours in his basement, but was kind of an \u201codd\u201d fellow.\\n\\nFortunately, debugging, like any other skill, is <strong>something that can be learned.<\/strong>\\n\\n<a href=\"http:\/\/amzn.to\/2cdnr6V\">If you apply the right techniques<\/a> and practice, you can become great at it.\\n\\nWho knows? You might even enjoy it.\\n\\n<strong>The key to debugging is realizing that it\u2019s all about mindset.<\/strong>\\n\\nIt\u2019s about taking a systematic approach to the problem\u2014not rushing it, and not expecting you can just find the problem, get in, and get out.\\n\\nIt\u2019s about staying calm and collected: <a href=\"https:\/\/simpleprogrammer.com\/programming-logic-get-better\/\">attacking the problem from a logical and analytical perspective<\/a> instead of an emotional one.\\n\\nIn this chapter, I\u2019m going to lay out a systematic approach to debugging, which will help you to avoid that dreaded debugger mindset and take your debugging skills to the next level.\\n\\n<\/p>\n<h2>What Is Debugging?<\/h2>\n<p>\\n\\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-21984\" src=\"https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/02\/Bug-Searching-1-1024x576.png\" alt=\"\" width=\"706\" height=\"397\" srcset=\"https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/02\/Bug-Searching-1-1024x576.png 1024w, https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/02\/Bug-Searching-1-300x169.png 300w, https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/02\/Bug-Searching-1-768x432.png 768w, https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/02\/Bug-Searching-1.png 1280w\" sizes=\"auto, (max-width: 706px) 100vw, 706px\" \/>\\n\\nBefore we dive deep, let\u2019s go shallow.\\n\\nWhat exactly is debugging?\\n\\nIt seems pretty obvious, right?\\n\\nYou open up the debugger and you \u201cdebug\u201d problems with the code.\\n\\nAh, but that is where you are wrong.\\n\\n<strong>Debugging has nothing to do with the debugger.<\/strong>\\n\\nDebugging has everything to do with <strong>finding the source of a problem<\/strong> in a code base, <strong>identifying the possible causes, testing out hypotheses <\/strong>until the ultimate root cause is found, and then eventually <strong>eliminating that cause<\/strong> and <strong>ensuring that it will never happen again.<\/strong>\\n\\nOk, I suppose we could call that fixing bugs. Semantics.\\n\\nThe point is, debugging is more than fiddling around in a debugger and changing code until it seems to work.\\n\\n<\/p>\n<h2>First Rule of Debugging: Don\u2019t Use the Debugger<\/h2>\n<p>\\n\\nAh, what\u2019s this you say?\\n\\nA new bug for me to fix?\\n\\nOh, this is a hairy one?\\n\\nHave no fear, sir. I will unleash the full power of my mental arsenal on this unholy terror.\\n\\nWith that mindset, you the programmer sit down at your desk.\\n\\nYou fire up the debugger.\\n\\nCarefully you step through the code.\\n\\nTime seems to blur, minutes turn into hours, hours into weeks.\\n\\nYou are an old man sitting at the keyboard, still in the same debugging session, but somehow you are \u201ccloser.\u201d\\n\\nYour children have all grown. Your wife has left you.\\n\\nThe only thing that remains is\u2026 the bug.\\n\\n<strong>The first thing most programmers do when they want to debug an issue in the code is to fire up the good old debugger and start looking around.<\/strong>\\n\\nWrong.\\n\\nDon\u2019t do this.\\n\\n<strong>The debugger should be your last resort.<\/strong>\\n\\nWhen you fire up the debugger immediately, you are effectively saying, \u201cI don\u2019t have any idea what is causing the issue, but I\u2019m just going to look around and see.\u201d\\n\\nIt\u2019s like when your car breaks down and you don\u2019t know jack shit about cars, so you open up the hood and look for something wrong.\\n\\nWhat are you looking for?\\n\\nYou don\u2019t even know.\\n\\nDon\u2019t get me wrong.\\n\\nThe debugger is a wonderful and powerful tool.\\n\\nUsed properly, the debugger can help you solve all kinds of problems and can help you see what happens when your code is running.\\n\\nIt\u2019s not, however, the place to start, and <strong>many bugs can be solved without ever touching the debugger.<\/strong>\\n\\nYou see, just like Facebook or funny YouTube cat videos, the debugger has a way of sucking you in.\\n\\n<\/p>\n<h2>Reproduce the Error<img loading=\"lazy\" decoding=\"async\" class=\"wp-image-21985 alignright\" src=\"https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/02\/Depositphotos_32914487_l-2015-1-1-1024x1024.jpg\" alt=\"\" width=\"352\" height=\"352\" srcset=\"https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/02\/Depositphotos_32914487_l-2015-1-1-1024x1024.jpg 1024w, https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/02\/Depositphotos_32914487_l-2015-1-1-300x300.jpg 300w, https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/02\/Depositphotos_32914487_l-2015-1-1-150x150.jpg 150w, https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/02\/Depositphotos_32914487_l-2015-1-1-768x768.jpg 768w, https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/02\/Depositphotos_32914487_l-2015-1-1-1536x1536.jpg 1536w, https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/02\/Depositphotos_32914487_l-2015-1-1.jpg 2000w\" sizes=\"auto, (max-width: 352px) 100vw, 352px\" \/><\/h2>\n<p>\\n\\nSo, if you don\u2019t simply fire up the debugger to debug a problem, what do you do?\\n\\nWell, I\u2019m glad you asked.\\n\\nThe first thing any sane person should do is to<strong> reproduce the bug to make sure that it is actually a bug<\/strong> and that you will be able to debug it.\\n\\nOne-hundred percent of problems that can\u2019t be reproduced can\u2019t be debugged.\\n\\nSo, <strong>if you can\u2019t reproduce the problem, there ain\u2019t no point in debugging it.<\/strong> Ya hear me?\\n\\nNot only can you not debug a problem that can\u2019t be reproduced, but also, even if you did fix it, you can\u2019t verify it was fixed.\\n\\nSo, the very first thing you should do when you are trying to debug a bug is to make sure you can reproduce the bug yourself.\\n\\nIf you can\u2019t, go and get help.\\n\\nIf a tester filed the bug, get them to reproduce it for you.\\n\\n<strong>If the bug is intermittent and can\u2019t be reliably reproduced, this means that you do not know the circumstances required to reproduce the problem.<\/strong>\\n\\nThere is no such thing as an intermittent problem.\\n\\nIf it is a problem, it can be reproduced; you just have to know how.\\n\\n<strong><em>Side note on intermittent problems:<\/em><\/strong>\\n\\n<em>Ok, so your boss is demanding that you fix the problem.<\/em>\\n\\n<em>They\u2019ve seen it in production. <a href=\"https:\/\/simpleprogrammer.com\/customer-centric-programming\/\">Customers have seen it<\/a>. It\u2019s definitely a problem.<\/em>\\n\\n<em>The \u201cI can\u2019t reproduce it\u201d pushback is not working\u2014they aren\u2019t buying it.<\/em>\\n\\n<em>What do you do?<\/em>\\n\\n<em>You still can\u2019t debug a problem that you can\u2019t reproduce.<\/em>\\n\\n<em>But what you can do is gather more evidence.<\/em>\\n\\n<em>Insert logging statements in the code.<\/em>\\n\\n<em>Gather as many details as possible about when the problem happens and under what conditions it happens.<\/em>\\n\\n<em>Artificially recreate the environment and circumstances if you can.<\/em>\\n\\n<em>Do not be tempted to throw in \u201cfixes\u201d for the problem that you can\u2019t recreate.<\/em>\\n\\n<em>If you don\u2019t understand the problem enough to recreate it, you have a very, very low chance of accidentally fixing it by a guess, and you will have an extremely difficult time knowing if your fix even worked.<\/em>\\n\\n<em>Find a way to reproduce the problem, even if it is only reproducible in production.<\/em>\\n\\n<\/p>\n<h2>Sit and Think<\/h2>\n<p>\\n\\nAfter you can reproduce your issue, the next step is a step most software developers skip because they are so eager to solve the problem\u2014but this step is crucial.\\n\\nIt\u2019s a really simple step.\\n\\n<strong>Just sit and think.<\/strong>\\n\\nYes, that\u2019s right.\\n\\nThink about the problem and what the possible causes could be.\\n\\nThink about how the system works and what might bring about the odd behavior you&#8217;re seeing.\\n\\nYou are going to be in a rush to jump into the code and into the debugger and start \u201clooking at things,\u201d but before you start looking at things, <strong>it\u2019s important to know what you are looking for and what things to look at.<\/strong>\\n\\nYou\u2019ll likely come up with a few ideas or hypotheses about what might be causing the issues.\\n\\nIf you don\u2019t, be patient. Keep sitting and thinking.\\n\\nStand and walk around if it helps, but before you move on, you should at least have a few ideas that you want to test.\\n\\nIf you absolutely can\u2019t come up with anything, continue to resist firing up the debugger, and instead <strong>take a browse through the source code <\/strong>and see if you can gather a few more clues about how the system is supposed to work.\\n\\nYou should have at least <strong>two or three good hypotheses<\/strong> you can test before you move on from this step.\\n\\n<\/p>\n<h2>Test Your Hypotheses<\/h2>\n<p>\\n\\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-21986\" src=\"https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/02\/Testing-1-1024x576.png\" alt=\"\" width=\"711\" height=\"400\" srcset=\"https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/02\/Testing-1-1024x576.png 1024w, https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/02\/Testing-1-300x169.png 300w, https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/02\/Testing-1-768x432.png 768w, https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/02\/Testing-1.png 1280w\" sizes=\"auto, (max-width: 711px) 100vw, 711px\" \/>\\n\\nOk, so you\u2019ve got some good hypotheses, right?\\n\\nThe flux-capacitor is connected to the thingamabob, so if the voltage coming out of the whozitswatt is below grade\u2026 THE THINGAMABOB MUST BE CONFIGURED INCORRECTLY!\\n\\nErr\u2026 something like that.\\n\\nOk, let\u2019s fire up the debugger and test our hypotheses! Yeah, man, let\u2019s do it!\\n\\nNo! Wrong.\\n\\nHold up there, young buck.\\n\\n<strong>We don\u2019t need the debugger just yet.<\/strong>\\n\\nWait, what? How am I going to test my hypotheses if I can\u2019t use the debugger, you ask?\\n\\nUnit tests.\\n\\nYes, that\u2019s right: unit tests.\\n\\n<strong>Try to write a unit test to test your hypotheses.<\/strong>\\n\\nIf you think some part of the system isn\u2019t working correctly, write a unit test that you think will exploit the issue.\\n\\nIf you are right and you\u2019ve found the problem, you can fix it right then and there, and now you will have a unit test in place to verify the fix and ensure it never happens again.\\n\\n(Still make sure you try and reproduce the actual bug, though, before you call it fixed.)\\n\\nIf you are wrong and the unit test you write passes as expected, <strong>you\u2019ve just made the system a little more robust<\/strong> by adding another unit test to the project, and you\u2019ve disproved one of your hypotheses.\\n\\nThink of it as ratcheting up the problem space.\\n\\n<strong>Every time you write a unit test and it passes, you are eliminating possibilities.<\/strong> You are traversing through your debugging journey by locking and closing doors behind you as soon as you find out they are dead-ends.\\n\\nIf you\u2019ve ever been lost for hours or days in a debugging session, you should immediately realize how valuable this is.\\n\\nOne of the reasons why the debugger is so bad is because <strong>it can encourage us to revisit the same wrong corridors over and over again<\/strong> as we check and recheck our assumptions, either forgetting what we already looked for or not trusting that we looked hard enough.\\n\\nA unit test is like climbing a mountain and putting an anchor in place that makes sure you can\u2019t fall too far backwards.\\n\\nWriting unit tests to test your hypotheses will also ensure that you aren\u2019t haphazardly trying things and looking around.\\n\\nYou have to have a specific assumption you are testing when you write a unit test in order to help debug a problem.\\n\\nNow, I\u2019m a realist.\\n\\nI\u2019m pragmatic.\\n\\n<strong>I know that sometimes it will be extremely difficult or impossible to write a unit test to test a hypothesis.<\/strong>\\n\\nIn this case, it\u2019s ok to fire up the debugger, but only if you obey this one rule:\\n\\n<strong>Have a specific purpose for doing it.<\/strong>\\n\\nKnow exactly what you are looking for and what you are checking when you use the debugger.\\n\\nDon\u2019t merely go in there to look around.\\n\\nI know it may seem like I\u2019m being a bit anal and pedantic about this whole thing but trust me, there is a reason for it.\\n\\n<a href=\"http:\/\/amzn.to\/2cGkWMy\">I want you to become a skilled debugger<\/a>, and you are only going to get that way by being deliberate about how you debug.\\n\\n<\/p>\n<h2>Check Your Assumptions<\/h2>\n<p>\\n\\nMost of the time, your hypotheses are not going to pan out.\\n\\nThat\u2019s just life.\\n\\nIf that\u2019s the case, the next best thing you can do is to check your assumptions about how things are working.\\n\\n<strong>We typically assume that code is working a certain way or that some input or output must be some value.<\/strong>\\n\\nOften we think, \u201cWell, this can\u2019t possibly be happening. I\u2019m looking at the code right here. There is no way it could be producing this output.\u201d\\n\\nOften, we are wrong.\\n\\nIt happens to the best of us.\\n\\n<strong>The best thing you can do with these assumptions is to check them.<\/strong>\\n\\nAnd what\u2019s the best way to check them?\\n\\nYes, that\u2019s right. More unit tests.\\n\\nWrite some unit tests that check obvious things which \u201chave to be working\u201d along the workflow of the problem you are trying to debug.\\n\\nMost of these tests should easily pass, and you\u2019ll say, \u201cDuh.\u201d\\n\\nBut, every once in awhile, you\u2019ll write a unit test to test some obvious assumption and the results will shock you.\\n\\n<strong>Remember, if the answer to your problem was obvious, it wouldn\u2019t be a problem at all.<\/strong>\\n\\nOnce again, the pragmatist side of me has to tell you that, yes, it\u2019s ok to open up the debugger to check your assumptions as well.\\n\\nBut only after you\u2019ve tried to check the assumptions using unit tests first.\\n\\nAgain, it\u2019s like climbing that mountain and putting in anchors along the way.\\n\\nAvoid the debugger if you can, use it if you must, but, once again, only to validate or invalidate specific assumptions you have already formed.\\n\\n<\/p>\n<h2>Divide and Conquer<img loading=\"lazy\" decoding=\"async\" class=\" wp-image-21987 alignright\" src=\"https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/02\/Depositphotos_61400659_s-2015-1.jpg\" alt=\"\" width=\"353\" height=\"353\" \/><\/h2>\n<p>\\n\\nI remember working on a really hairy bug with a printer incorrectly interpreting a print file written in the PostScript printing language.\\n\\nI tried everything I could think of to debug the problem.\\n\\nI tested all kinds of hypotheses.\\n\\nNothing panned out.\\n\\nIt seemed like the bug was some kind of combination of multiple commands in the print file, and I had no idea which ones it was.\\n\\nSo, what did I do?\\n\\nWell, I cut the print file in half.\\n\\nThe bug was still there.\\n\\nSo, I cut it in half again.\\n\\nIt disappeared this time.\\n\\nI tried the other half. Back again.\\n\\nI kept hacking away at big chucks of the print file until I got the entire file down from several thousand lines of code to just five.\\n\\n<strong>The five lines of code that, in that order, produced the bug.<\/strong>\\n\\nEasy peasy.\\n\\n<strong>Sometimes when you get stuck debugging, what you need to do is figure out a way to cut the problem in half\u2014<\/strong>or take as big of a chunk out of it as possible.\\n\\nDepending on the problem, this could look very different, but <strong>try and think of ways you can eliminate a large amount of code<\/strong> or remove a large amount of the system or variables and still reproduce the bug.\\n\\nSee if you can come up with tests which completely eliminate parts of the system for being responsible for the error.\\n\\nThen do it again\u2026 and again.\\n\\nIf you keep hacking away, you\u2019ll likely find the critical components required to create the error, and then the problem can become relatively easy to solve.\\n\\n<\/p>\n<h2>If You Fix It, Understand Why<\/h2>\n<p>\\n\\nI\u2019m going to give you one final piece of advice about debugging\u2014although I\u2019m sure I could write a whole book on the subject.\\n\\n<strong>If you fix a problem, understand why what you did fixed it.<\/strong>\\n\\nIf you don\u2019t understand why what you did fixed the problem, you are not done yet.\\n\\nYou may have inadvertently caused a different problem, or\u2014very likely\u2014you haven\u2019t fixed your original problem.\\n\\n<strong>Problems don\u2019t go away on their own.<\/strong>\\n\\nIf you didn\u2019t fix the problem, I can guarantee you it\u2019s not fixed. It\u2019s just hiding.\\n\\nBut if you did fix the problem, don\u2019t stop there. Explore a little deeper, and make sure you understand exactly what was going on that caused the problem in the first place and how what you did fixed it.\\n\\nToo many software developers debug a problem by twiddling bits, the code apparently starts working, and they assume it is fixed without even knowing why.\\n\\nThis is a dangerous habit for many reasons.\\n\\nAs I mentioned above, <strong>when you randomly tweak things in the system and change bits of code here and there, you could be causing all kinds of other problems which you aren\u2019t aware of.<\/strong>\\n\\nBut, perhaps more than that, you are training yourself to be a shitty debugger.\\n\\nYou are developing the habit of messing with things until it works. No technique, no rigor.\\n\\nYou may get lucky sometimes, but you won\u2019t have a repeatable process or reliable skillset for debugging.\\n\\n<strong>Not only should you understand what broke, why, and how you fixed it, but also you should verify the fix.<\/strong>\\n\\nI know it seems like common knowledge, but I can\u2019t tell you how much time is wasted by programmers \u201cfixing a problem,\u201d assuming the fix worked, and passing the code to QA only for QA to reproduce the problem and have it go back to the developer who has to start over at square one again.\\n\\nIt\u2019s a huge waste of time that can be prevented by taking an extra five minutes to verify that what you fixed is actually fixed.\\n\\nIn fact, don\u2019t just verify the fix; <strong>write a regression test for the problem so that it never happens again.<\/strong>\\n\\nIf you truly understand the problem you fixed, you should be able to write a unit test that exploits the issue, and then your fix should make that unit test pass.\\n\\nFinally,<strong> look for other instances of this same class of bug.<\/strong>\\n\\nBugs tend to hang out together.\\n\\nIf you found something wrong with one assumption you made about the system or some incorrectly coded component, it\u2019s very likely that there are other issues which are also caused by that same problem.\\n\\nAgain, this is why it is so critical that you understand what the real problem was and why your solution fixed it.\\n\\nIf you know what happened and why, you can quickly figure out if there are likely to be other issues caused by the same underlying problem.\\n\\n<\/p>\n<h2>Art and Science<\/h2>\n<p>\\n\\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-21988\" src=\"https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/02\/Bug-1-1024x576.png\" alt=\"\" width=\"754\" height=\"424\" srcset=\"https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/02\/Bug-1-1024x576.png 1024w, https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/02\/Bug-1-300x169.png 300w, https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/02\/Bug-1-768x432.png 768w, https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/02\/Bug-1.png 1280w\" sizes=\"auto, (max-width: 754px) 100vw, 754px\" \/>\\n\\nRemember, debugging\u2014like software development\u2014is part art and part science.\\n\\n<strong>You can only get good at debugging by practicing.<\/strong>\\n\\nBut practicing is not enough. You have to specifically, systematically debug, not just play around in the debugger.\\n\\nHopefully, I\u2019ve given you a good overview of how to do that; now the rest is up to you.\\n\\n<\/p>\n<hr \/>\n<p>\\n\\n<a href=\"https:\/\/simpleprogrammer.com\/products\/careerguide\/\"><img decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/06\/Site-Ad.png\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>As a software developer, I can guarantee you one thing for sure: you are going to spend a great deal of time debugging code.\\n\\nThere are certain constants in life which are unavoidable: death, taxes, and programmers creating bugs.\\n\\nSince so much of your time will be spent debugging code, it\u2019s probably a good idea for a&#8230;<\/p>\n","protected":false},"author":2,"featured_media":21989,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","footnotes":""},"categories":[162229812,70886,31679,162229803,162229823,162229253],"tags":[],"class_list":["post-21982","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-advice","category-debugging","category-process-improvement","category-programming","category-software","category-technical"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>A Programmer&#039;s Guide To Effective Debugging - Simple Programmer<\/title>\n<meta name=\"description\" content=\"As a software developer, you are going to spend a great deal of time debugging code. Therefore, it&#039;s probably a good idea to know how to do it effectively.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/simpleprogrammer.com\/effective-debugging\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"A Programmer&#039;s Guide To Effective Debugging - Simple Programmer\" \/>\n<meta property=\"og:description\" content=\"As a software developer, you are going to spend a great deal of time debugging code. Therefore, it&#039;s probably a good idea to know how to do it effectively.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/simpleprogrammer.com\/effective-debugging\/\" \/>\n<meta property=\"og:site_name\" content=\"Simple Programmer\" \/>\n<meta property=\"article:published_time\" content=\"2017-02-06T15:00:30+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-02-12T06:20:56+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/02\/A-Programmers-Guide-To-Effective-Debugging.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"720\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"John Sonmez\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"John Sonmez\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"15 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/effective-debugging\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/effective-debugging\\\/\"},\"author\":{\"name\":\"John Sonmez\",\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/#\\\/schema\\\/person\\\/1abc70edfb189184827740310672de67\"},\"headline\":\"A Programmer&#8217;s Guide To Effective Debugging\",\"datePublished\":\"2017-02-06T15:00:30+00:00\",\"dateModified\":\"2023-02-12T06:20:56+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/effective-debugging\\\/\"},\"wordCount\":3221,\"commentCount\":8,\"image\":{\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/effective-debugging\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/simpleprogrammer.com\\\/wp-content\\\/uploads\\\/2017\\\/02\\\/A-Programmers-Guide-To-Effective-Debugging.png\",\"articleSection\":[\"Advice\",\"Debugging\",\"Process Improvement\",\"Programming\",\"Software\",\"Technical\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/simpleprogrammer.com\\\/effective-debugging\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/effective-debugging\\\/\",\"url\":\"https:\\\/\\\/simpleprogrammer.com\\\/effective-debugging\\\/\",\"name\":\"A Programmer's Guide To Effective Debugging - Simple Programmer\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/effective-debugging\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/effective-debugging\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/simpleprogrammer.com\\\/wp-content\\\/uploads\\\/2017\\\/02\\\/A-Programmers-Guide-To-Effective-Debugging.png\",\"datePublished\":\"2017-02-06T15:00:30+00:00\",\"dateModified\":\"2023-02-12T06:20:56+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/#\\\/schema\\\/person\\\/1abc70edfb189184827740310672de67\"},\"description\":\"As a software developer, you are going to spend a great deal of time debugging code. Therefore, it's probably a good idea to know how to do it effectively.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/effective-debugging\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/simpleprogrammer.com\\\/effective-debugging\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/effective-debugging\\\/#primaryimage\",\"url\":\"https:\\\/\\\/simpleprogrammer.com\\\/wp-content\\\/uploads\\\/2017\\\/02\\\/A-Programmers-Guide-To-Effective-Debugging.png\",\"contentUrl\":\"https:\\\/\\\/simpleprogrammer.com\\\/wp-content\\\/uploads\\\/2017\\\/02\\\/A-Programmers-Guide-To-Effective-Debugging.png\",\"width\":1280,\"height\":720},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/effective-debugging\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/simpleprogrammer.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"A Programmer&#8217;s Guide To Effective Debugging\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/#website\",\"url\":\"https:\\\/\\\/simpleprogrammer.com\\\/\",\"name\":\"Simple Programmer\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/simpleprogrammer.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/simpleprogrammer.com\\\/#\\\/schema\\\/person\\\/1abc70edfb189184827740310672de67\",\"name\":\"John Sonmez\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/dc2f18dfa76e017566ce607de002d7abe4acfd5ec19a6db82c180b00867b8d94?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/dc2f18dfa76e017566ce607de002d7abe4acfd5ec19a6db82c180b00867b8d94?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/dc2f18dfa76e017566ce607de002d7abe4acfd5ec19a6db82c180b00867b8d94?s=96&d=mm&r=g\",\"caption\":\"John Sonmez\"},\"url\":\"https:\\\/\\\/simpleprogrammer.com\\\/author\\\/jsonmez\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"A Programmer's Guide To Effective Debugging - Simple Programmer","description":"As a software developer, you are going to spend a great deal of time debugging code. Therefore, it's probably a good idea to know how to do it effectively.","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:\/\/simpleprogrammer.com\/effective-debugging\/","og_locale":"en_US","og_type":"article","og_title":"A Programmer's Guide To Effective Debugging - Simple Programmer","og_description":"As a software developer, you are going to spend a great deal of time debugging code. Therefore, it's probably a good idea to know how to do it effectively.","og_url":"https:\/\/simpleprogrammer.com\/effective-debugging\/","og_site_name":"Simple Programmer","article_published_time":"2017-02-06T15:00:30+00:00","article_modified_time":"2023-02-12T06:20:56+00:00","og_image":[{"width":1280,"height":720,"url":"https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/02\/A-Programmers-Guide-To-Effective-Debugging.png","type":"image\/png"}],"author":"John Sonmez","twitter_card":"summary_large_image","twitter_misc":{"Written by":"John Sonmez","Est. reading time":"15 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/simpleprogrammer.com\/effective-debugging\/#article","isPartOf":{"@id":"https:\/\/simpleprogrammer.com\/effective-debugging\/"},"author":{"name":"John Sonmez","@id":"https:\/\/simpleprogrammer.com\/#\/schema\/person\/1abc70edfb189184827740310672de67"},"headline":"A Programmer&#8217;s Guide To Effective Debugging","datePublished":"2017-02-06T15:00:30+00:00","dateModified":"2023-02-12T06:20:56+00:00","mainEntityOfPage":{"@id":"https:\/\/simpleprogrammer.com\/effective-debugging\/"},"wordCount":3221,"commentCount":8,"image":{"@id":"https:\/\/simpleprogrammer.com\/effective-debugging\/#primaryimage"},"thumbnailUrl":"https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/02\/A-Programmers-Guide-To-Effective-Debugging.png","articleSection":["Advice","Debugging","Process Improvement","Programming","Software","Technical"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/simpleprogrammer.com\/effective-debugging\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/simpleprogrammer.com\/effective-debugging\/","url":"https:\/\/simpleprogrammer.com\/effective-debugging\/","name":"A Programmer's Guide To Effective Debugging - Simple Programmer","isPartOf":{"@id":"https:\/\/simpleprogrammer.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/simpleprogrammer.com\/effective-debugging\/#primaryimage"},"image":{"@id":"https:\/\/simpleprogrammer.com\/effective-debugging\/#primaryimage"},"thumbnailUrl":"https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/02\/A-Programmers-Guide-To-Effective-Debugging.png","datePublished":"2017-02-06T15:00:30+00:00","dateModified":"2023-02-12T06:20:56+00:00","author":{"@id":"https:\/\/simpleprogrammer.com\/#\/schema\/person\/1abc70edfb189184827740310672de67"},"description":"As a software developer, you are going to spend a great deal of time debugging code. Therefore, it's probably a good idea to know how to do it effectively.","breadcrumb":{"@id":"https:\/\/simpleprogrammer.com\/effective-debugging\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/simpleprogrammer.com\/effective-debugging\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/simpleprogrammer.com\/effective-debugging\/#primaryimage","url":"https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/02\/A-Programmers-Guide-To-Effective-Debugging.png","contentUrl":"https:\/\/simpleprogrammer.com\/wp-content\/uploads\/2017\/02\/A-Programmers-Guide-To-Effective-Debugging.png","width":1280,"height":720},{"@type":"BreadcrumbList","@id":"https:\/\/simpleprogrammer.com\/effective-debugging\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/simpleprogrammer.com\/"},{"@type":"ListItem","position":2,"name":"A Programmer&#8217;s Guide To Effective Debugging"}]},{"@type":"WebSite","@id":"https:\/\/simpleprogrammer.com\/#website","url":"https:\/\/simpleprogrammer.com\/","name":"Simple Programmer","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/simpleprogrammer.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/simpleprogrammer.com\/#\/schema\/person\/1abc70edfb189184827740310672de67","name":"John Sonmez","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/dc2f18dfa76e017566ce607de002d7abe4acfd5ec19a6db82c180b00867b8d94?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/dc2f18dfa76e017566ce607de002d7abe4acfd5ec19a6db82c180b00867b8d94?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/dc2f18dfa76e017566ce607de002d7abe4acfd5ec19a6db82c180b00867b8d94?s=96&d=mm&r=g","caption":"John Sonmez"},"url":"https:\/\/simpleprogrammer.com\/author\/jsonmez\/"}]}},"_links":{"self":[{"href":"https:\/\/simpleprogrammer.com\/wp-json\/wp\/v2\/posts\/21982","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/simpleprogrammer.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/simpleprogrammer.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/simpleprogrammer.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/simpleprogrammer.com\/wp-json\/wp\/v2\/comments?post=21982"}],"version-history":[{"count":0,"href":"https:\/\/simpleprogrammer.com\/wp-json\/wp\/v2\/posts\/21982\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/simpleprogrammer.com\/wp-json\/wp\/v2\/media\/21989"}],"wp:attachment":[{"href":"https:\/\/simpleprogrammer.com\/wp-json\/wp\/v2\/media?parent=21982"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/simpleprogrammer.com\/wp-json\/wp\/v2\/categories?post=21982"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/simpleprogrammer.com\/wp-json\/wp\/v2\/tags?post=21982"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}