<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ bugs - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ bugs - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Tue, 23 Jun 2026 22:45:28 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/bugs/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ How to Report a Bug to freeCodeCamp ]]>
                </title>
                <description>
                    <![CDATA[ Thank you for taking the time to report an issue with freeCodeCamp. If you think you’ve found a bug on freeCodeCamp, please follow these steps to resolve your problem: Reset the Code in the Editor Try resetting the code in the editor using the reset ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-report-a-bug-to-freecodecamp/</link>
                <guid isPermaLink="false">66c354225f85c1948b3fabb3</guid>
                
                    <category>
                        <![CDATA[ bugs ]]>
                    </category>
                
                    <category>
                        <![CDATA[ debugging ]]>
                    </category>
                
                    <category>
                        <![CDATA[ freeCodeCamp.org ]]>
                    </category>
                
                    <category>
                        <![CDATA[ GitHub ]]>
                    </category>
                
                    <category>
                        <![CDATA[ learn to code ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Tue, 03 May 2022 21:07:57 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2022/05/pexels-pixabay-144243.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Thank you for taking the time to report an issue with freeCodeCamp.</p>
<p>If you think you’ve found a bug on freeCodeCamp, please follow these steps to resolve your problem:</p>
<h2 id="heading-reset-the-code-in-the-editor">Reset the Code in the Editor</h2>
<p>Try resetting the code in the editor using the reset button on the page. This will solve most of the issues if somehow you changed some code that is affecting the challenge in some way. </p>
<p>Resetting clears the code to its original state as it was when the challenge was first presented to you.</p>
<h2 id="heading-use-a-coding-keyboard-or-the-app-on-mobile">Use a Coding Keyboard or the App on Mobile</h2>
<p>Try reading this article about <a target="_blank" href="https://www.freecodecamp.org/news/freecodecamp-mobile/">How to use freeCodeCamp on a mobile phone</a>. Or if you are using an Android device, check if the <a target="_blank" href="https://play.google.com/store/apps/details?id=org.freecodecamp&amp;gl=US">freeCodeCamp App</a> has the feature you are wanting to use.</p>
<h2 id="heading-do-a-hard-refresh">Do a Hard Refresh</h2>
<p>If the page seems broken in any way, try to do a Hard Refresh of the page. This will update any old code that may have been cached in your browser. </p>
<p>If the freeCodeCamp website was recently deployed, and the issues come from that, this will be enough to fix it.</p>
<h3 id="heading-how-to-do-an-hard-refresh">How to do an Hard Refresh</h3>
<p>While on the problematic page, use the key combination below to trigger a hard refresh depending on your operating system:</p>
<ul>
<li>Windows: <code>CTRL + F5</code></li>
<li>Mac/Apple: <code>Apple + Shift + R or Command + Shift + R</code></li>
<li>Linux: <code>F5</code></li>
</ul>
<p>To learn more about this read: <a target="_blank" href="http://refreshyourcache.com/en/cache/">http://refreshyourcache.com/en/cache/ 73</a></p>
<h2 id="heading-try-clearing-your-browsers-local-storage">Try Clearing Your Browser's Local Storage</h2>
<p>Removing all your locally stored challenges will solve many problems related to the browser crashing on freeCodeCamp</p>
<h3 id="heading-in-chrome">In Chrome:</h3>
<ul>
<li>On freecodecamp.org open your console</li>
<li>Windows: <code>Ctrl</code> + <code>Shift</code> + <code>J</code></li>
<li>Mac OS: <code>Cmd</code> + <code>Opt</code> + <code>J</code></li>
<li>Go to resources tab (Chrome).</li>
<li>There, click on the “Local Storage” link in the nav bar on the right.</li>
<li>Delete all the entries on the right side, or run this command in your browser’s console to clear all entries from your localStorage: <code>localStorage.clear();</code></li>
<li>See if this solves your issue</li>
</ul>
<h3 id="heading-how-to-remove-a-single-challenge-from-local-storage">How to remove a single challenge from Local Storage</h3>
<p>Maybe you don't want to lose the code from other challenges or something like that. This method will remove only the problematic challenge from your browser's Local Storage.</p>
<h4 id="heading-in-chrome-1">In Chrome:</h4>
<ul>
<li>On  <strong>freecodecamp.org</strong>, open your developer tools.</li>
<li>More tools &gt; Developer tools (or  <code>Ctrl</code>  +  <code>Shift</code>  +  <code>I</code>  (Windows),  <code>Cmd</code>  +  <code>Opt</code>  +  <code>I</code>  (Mac))</li>
<li>Navigate to the  <code>Resources</code>  tab</li>
<li>Expand the  <code>Local Storage</code> item in the left pane</li>
<li>Select  <code>http://www.freecodecamp.org</code></li>
<li>Find the challenge for which you wish to delete data in the right pane</li>
<li>Right click the desired challenge and select <code>Delete</code></li>
</ul>
<h4 id="heading-in-firefox">In Firefox:</h4>
<ul>
<li>On  <strong>freecodecamp.org</strong>, open your web console with</li>
<li><code>Ctrl</code>  +  <code>Shift</code>  +  <code>K</code></li>
<li>From there, using directly the console:</li>
<li>Type  <code>console.log(localStorage);</code>  and hit  <code>Enter</code> .</li>
<li>Click in  <code>Storage</code>  link.</li>
<li>The  <strong>Storage</strong>  panel will appear at right.</li>
<li>Filter the results to find the Algorithm, Front End Project or Challenge causing the problem.</li>
<li>When located, mouse over it and click the  <code>x</code>  at right.</li>
<li>Once removed, check if the problem was solved. Refresh or close and open the browser if necessary.</li>
</ul>
<p><strong>Note:</strong>  This can also be done with the <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Tools/Storage_Inspector">Storage Inspector</a>, but seems like Firefox hangs out when there are so many values.</p>
<h2 id="heading-check-if-the-issue-is-caused-by-one-of-your-browser-extensions">Check if the issue is caused by one of your browser extensions</h2>
<p>Try deactivating your browser extensions, or try to open the page in your browser private mode.</p>
<p>If in this way the issue is fixed, you will need to put in an exception for freeCodeCamp in the guilty extension, or keep it switched off while you are using the freeCodeCamp website.</p>
<h2 id="heading-read-the-support-faqs">Read the Support FAQs</h2>
<p>The <a target="_blank" href="https://www.freecodecamp.org/news/support">support FAQs</a> offer solutions for many common issues. Try reading through that article if the steps above didn't work or were not related to your issue.</p>
<h2 id="heading-ask-for-help-on-the-forum">Ask for Help on the Forum</h2>
<p>You may have arrived here and still have your issue. Now it's time to ask for help from other humans. </p>
<p><a target="_blank" href="http://forum.freecodecamp.com/">Open a topic on the forum describing your issue</a>. Try to give as much info as possible, including your code and the challenge link, or the link to the page affected, and your operating system (if you are on a challenge, you can use the "Ask for help" button to create a precompiled post with these issues already included, to which you can add your description of the issue and eventual screenshots). </p>
<p>There may be something going on with your code, or there may be a briefly occurring issue with freeCodeCamp in general.</p>
<h3 id="heading-how-to-format-code-on-the-forum">How to format code on the Forum</h3>
<p>When you enter a code block into a forum post, precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.</p>
<p>You can also use the “preformatted text” tool in the editor (<code>&lt;/&gt;</code>) to add backticks around text.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/05/Pre-formatted-text.gif" alt="Image" width="600" height="400" loading="lazy"></p>
<h2 id="heading-create-an-issue-on-github">Create an Issue on GitHub</h2>
<p>The forum may be able to help you, or may send you to GitHub.</p>
<p>Before creating a new issue on GitHub, try searching around the existing issues to see if someone has already reported something similar.</p>
<h3 id="heading-how-to-search-an-issue-on-github">How to search an issue on GitHub</h3>
<ol>
<li>Go to freeCodeCamp’s <a target="_blank" href="https://github.com/FreeCodeCamp/FreeCodeCamp/issues">Github Issues</a> page.</li>
<li>Use the search bar to search for already filed issues that may be related to your problem.</li>
<li>If you find one, read it! You can subscribe to get updates about that specific issue by clicking on <code>Subscribe</code> in the sidebar. You can add a reaction on the posts that best describe your issue, or you can also comment on the issue if you have something to add.</li>
<li>If you cannot find any relevant issues you should create a new GitHub Issue.</li>
</ol>
<h3 id="heading-how-to-create-a-new-issue-on-github">How to create a new Issue on GitHub</h3>
<p><strong>IMPORTANT:</strong><br>Before you report a new issue always get a third party confirmation from someone in the chat rooms or the forum. Remember that the issue tracker is strictly for reporting bugs or enhancements, it’s not a place to seek any help with solving the challenges.</p>
<p>Crafting a good issue will make it much easier for the dev team to replicate and resolve your problem. Follow these steps to do it right:</p>
<ul>
<li>Go to freeCodeCamp's <a target="_blank" href="https://github.com/FreeCodeCamp/FreeCodeCamp/issues">GitHub Issues</a> page and click on  <code>New Issue</code> .</li>
<li>Select the correct Issue type from the list</li>
</ul>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/05/image-19.png" alt="Image" width="600" height="400" loading="lazy"></p>
<ul>
<li><strong>Have a useful title.</strong> Write a meaningful title that describes the issue. Some good examples are  <code>Logging in from the News and Field Guide pages doesn't redirect properly (using e-mail)</code>  and  <code>Typo: "for" instead of "while" loop</code>; bad examples include  <code>A bug, HELP!!!11</code>  and  <code>I found this bug in a Challenge</code> .</li>
<li>Keep the title relatively short, as the description is for further information. One example is to shorten long Challenge names, so instead of writing  <code>Test case bug in 'Challenge: Check Radio Buttons and Checkboxes by Default'</code> , you might want to write  <code>Test case bug in 'Radio Buttons' Challenge</code> .</li>
<li>In the body,  <strong>provide a link</strong> to the page on which you encountered this issue.</li>
<li><strong>Describe the problem</strong> and <strong>provide steps</strong> so that a developer can try to replicate the issue. Include your operating system and browser version. When referencing other issues or pull requests, simply write #issue/pr-number.</li>
<li>Paste in any relevant code using proper code formatting</li>
<li><strong>Take a screenshot</strong> of the issue and include it in the post.</li>
<li>Click <code>Submit New Issue</code> and you are done! You will be automatically subscribed to notifications for any updates or future comments.</li>
</ul>
<h3 id="heading-how-to-format-the-code-on-github">How to format the code on GitHub</h3>
<p>You need to use three backticks <code>before your code block, and three backticks</code> after your code block.</p>
<p>You can also select your code block and use the button "Add code" in the GitHub editor.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/05/image-11.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>In this way your code will be formatted and more legible.</p>
<p>Resources compiled and edited by Ilenia Magoni, freeCodeCamp author and Italian localization and community leader.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Improve your Debugging Skills ]]>
                </title>
                <description>
                    <![CDATA[ By Ogundiran Ayobami ‌‌Whether you are a beginner or expert software developer, you probably find bugs in your code. ‌‌We all have bugs in our applications because no one knows everything about coding, and we sometimes make mistakes. After all, there... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-improve-your-debugging-skills/</link>
                <guid isPermaLink="false">66d84e70f6f7ca5a604624ca</guid>
                
                    <category>
                        <![CDATA[ bugs ]]>
                    </category>
                
                    <category>
                        <![CDATA[ debugging ]]>
                    </category>
                
                    <category>
                        <![CDATA[ self-improvement  ]]>
                    </category>
                
                    <category>
                        <![CDATA[ software development ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Wed, 24 Feb 2021 15:51:00 +0000</pubDate>
                <media:content url="https://cdn-media-2.freecodecamp.org/w1280/5fb8cb2d49c47664ed823f4b.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Ogundiran Ayobami</p>
<p>‌‌Whether you are a beginner or expert software developer, you probably find bugs in your code.</p>
<p>‌‌We all have bugs in our applications because no one knows everything about coding, and we sometimes make mistakes. After all, there is no way to stop being human.</p>
<p>‌‌Or can you show me how to develop a superpower? Ah alright then, never mind. :)</p>
<p>‌‌We can only study ourselves, our tools, and our bugs to find solutions that can help us be more efficient in reducing the bugs we create.</p>
<h2 id="heading-how-can-we-deal-with-bugs">How can we deal with bugs?</h2>
<p>There are three major ways to deal with bugs:</p>
<ol>
<li>Prebugging: the reduction of bugs before they're created</li>
<li>Debugging: identifying, fixing, and removing bugs once you find them</li>
<li>Post-debugging: expecting unexpected or unknown bugs</li>
</ol>
<p>Let's look at each one in detail.</p>
<h1 id="heading-what-is-prebugging">What is Prebugging?</h1>
<p>‌‌The late computer scientist <a target="_blank" href="https://en.wikipedia.org/wiki/Edsger_W._Dijkstra">Edsger W. Dijkstra</a> said, </p>
<blockquote>
<p>“If debugging is the process of removing bugs, then programming must be the process of putting them in.”</p>
</blockquote>
<p>‌‌If we introduce bugs to a program through programming, that means we need to guide ourselves to reduce the number of bugs we introduce. I call this process of guiding ourselves "Prebugging".</p>
<p>‌‌I searched "define: debugging" on Google and the definition I saw from the Oxford Dictionary got me thinking.</p>
<p>‌‌This is the definition: </p>
<blockquote>
<p>"[Debugging is] the process of identifying and removing errors from computer hardware or software."</p>
</blockquote>
<p>‌‌What? Is that the only thing we do?</p>
<p>‌‌The definition got me thinking because I am sure a lot of software developers are proactive about debugging. They improve their tools and themselves to reduce the number of bugs they create in the first place.</p>
<p>Some ways we can do that:</p>
<ol>
<li>Write program specs.‌‌</li>
<li>Learn to really understand the tools you use.‌</li>
<li>Learn to type accurately.‌ </li>
<li>Familiarize yourself with error messages and their probable solutions.‌‌</li>
<li>Always make sure you have setups that are stable for most of the tools you use.‌‌</li>
</ol>
<p>And a lot more!</p>
<p>‌‌The definition doesn't reflect all these aspects of debugging, and that forced me to think "Oh, no! Someone has to share all the things software developers do to reduce bugs."</p>
<p>‌‌Though the definition is acceptable for debugging, it downplays every other thing software developers do to reduce bug creation.‌‌ So let's go over those things now.</p>
<h3 id="heading-learn-the-basic-of-the-tools-you-use-often">💥Learn the basic of the tools you use often</h3>
<p>‌‌It is important to learn the basic of any tools you often use, because this helps you reduce the number of bugs you create while coding.</p>
<p>‌‌There is no way to avoid bug creation completely, but you can avoid creating some bugs if your knowledge of the basic of the tools you use is very sound.</p>
<p>‌‌For example, many JavaScript users can't remember what <code>splice()</code> returns. And some can't remember the difference between the <code>map()</code> and <code>forEach()</code> array methods.‌‌ What is the difference, anyway? Never mind! We're all guilty of it now and then.</p>
<p>‌‌If you are not a JavaScript user, just pick a built-in method or function from the language you use and ask yourself:</p>
<p>‌‌What kind of argument does this take? ‌‌What does this return? ‌‌What happens if an invalid argument is supplied?</p>
<p>‌‌Asking yourself the above questions about each of the built-in parts of whichever tool you use often can influence you to learn further and stay up to date.</p>
<p>‌‌That is how to keep yourself updated on the basics of the tools you often use especially if you don't have much time to read actively.</p>
<h3 id="heading-plan-before-coding">💥 Plan Before Coding</h3>
<p>Programming can seem like a trial and error sport where you do it until you get it right.</p>
<p>‌‌Many beginner software developers don't truly understand the programs they are working on and some of them don't actually try to understand error messages before googling them.</p>
<p>Everybody now seems to feel that programming is always about <em>"Code, Code, code, Search, Debug".</em></p>
<p>‌‌But it is necessary to really understand what you are doing so that you can quickly write out:</p>
<ul>
<li>What we expect to take as inputs as well as the structure and features of such inputs.‌‌</li>
<li>What we expect to do with the inputs.‌‌ </li>
<li>What we expect to return or do in the end in relation to the inputs or other things.‌‌</li>
<li>What we expect to do if the expected inputs are not given.</li>
</ul>
<p>‌‌In short, planning the inputs, processes, and outputs of a function or program doesn't only help you reduce bugs but also helps you write efficient tests.</p>
<h3 id="heading-familiarize-yourself-with-common-error-messages">💥 Familiarize yourself with common error messages</h3>
<p>It is often very easy to fix an error or a bug if you have familiarized yourself with that bug.</p>
<p>That is why it is important to take time to study some common errors and learn how to go about fixing them. Let's talk about some common errors now:</p>
<h4 id="heading-1-syntax-errors">1. Syntax Errors</h4>
<p>Every programming language has its own rules, and developers are liable to violate those rules.</p>
<p>‌‌Programming languages are strict about their rules and they will throw errors whenever those rules are violated. </p>
<p>Imagine, for example, that you omit the parentheses of a function or method like this:</p>
<p><code>function {}</code></p>
<p>An error will be thrown.</p>
<p>Familiarizing yourself with the error message of a syntax error and how to fix it will give you an edge while debugging it.</p>
<p>Personally, I have noticed that most syntax errors always mention some keywords that help you figure out the part of your code that is faulty.</p>
<pre><code><span class="hljs-keyword">let</span> school = { 
<span class="hljs-attr">name</span>: <span class="hljs-string">"Harvard"</span>, 
<span class="hljs-attr">location</span>: <span class="hljs-string">"Heaven On Earth"</span>, <span class="hljs-attr">admit</span>: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{ <span class="hljs-keyword">return</span> <span class="hljs-string">"weeew! You are admitted"</span> } 
} 
<span class="hljs-built_in">console</span>.log(school.names); <span class="hljs-comment">// undefined</span>
</code></pre><p>The "undefined" that's returned tells us whether the object or property we are accessing is not available. We can figure out where the problem is if we pay keen attention to the error message.</p>
<p>‌‌Now, let's take the example a bit further. </p>
<p><code>console.log(school.locations.address);</code> // Uncaught TypeError: Cannot read property 'address' of undefined.</p>
<p>‌‌If we pay close attention to the error message, we can easily figure out where the bug is.</p>
<p>‌‌From the error message above, "Cannot read property 'address' of undefined" means that address is a property and a property is known to be in an object (in JavaScript). But in this case, the object is said to be "undefined".</p>
<p>‌‌The more you code the more you get better at avoiding syntax errors. You can also simply use code editors, linters, or IDEs that highlight syntax errors. Using these tools can help you a lot.</p>
<p><strong>You can check out these code linters to see which one works best for your use case:</strong></p>
<p><a target="_blank" href="https://eslint.org/docs/user-guide/getting-started">ESLint</a> for JavaScript</p>
<p><a target="_blank" href="https://www.pylint.org/">PyLint</a> for Python</p>
<p><a target="_blank" href="https://github.com/checkstyle/checkstyle">Checkstyle</a> for Java</p>
<p><a target="_blank" href="https://github.com/squizlabs/PHP_CodeSniffer">PHP_CodeSniffer</a> for PHP</p>
<p>Also, most of the popular code editors like VSCode can be configured to use the code linters above.</p>
<h4 id="heading-2-logicsemantic-errors">2. Logic/Semantic Errors</h4>
<p>Logic errors are very tricky to deal with because they always seem like there is no error – but you still don't get the expected result.</p>
<p>For example, a simple way to confirm this kind of error is to check the code below in the browser's console.</p>
<p>‌<code>prompt("enter number") + 3;</code></p>
<p>You may expect a number as an output, but it will return a string. In short, you will not get the expected result.</p>
<p>Planning before coding and understanding the basics of the programming language you use can help you deal with logical errors – provided you understand the program requirements given to you.</p>
<h4 id="heading-3-compilation-errors">3. Compilation Errors</h4>
<p>Your program may not compile because you might have violated some rules the compiler expect you to stick to. So, the program you are working on may not compile.</p>
<p>For example, writing a string without the usual quotes, as in <code>const name = Ayobami</code>, will lead to a compilation error because a string must be quoted. So, the code will not compile.</p>
<p>‌‌This is similar to syntax errors, and the more you code, the more you get better at dealing with compilation errors.</p>
<p>You can be more effective and reduce these errors by compiling or testing your code often.</p>
<h4 id="heading-4-resource-errors">4. Resource Errors</h4>
<p>Sometimes, your program may exceed its memory limit or use up the available resources. That may lead your application to go out of service or malfunction.</p>
<p>The code below is a real-world example of code that leads to resource errors.</p>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">factorial</span>(<span class="hljs-params">num</span>) </span>{
  <span class="hljs-keyword">var</span> result = <span class="hljs-number">1</span>;
  <span class="hljs-keyword">for</span>(<span class="hljs-keyword">var</span> i = num; i &gt; <span class="hljs-number">0</span>; i--){
    result = num * factorial(num<span class="hljs-number">-1</span>);
  }
  <span class="hljs-keyword">return</span> result;
}

factorial(<span class="hljs-number">5</span>);
factorial(<span class="hljs-number">10</span>);
factorial(<span class="hljs-number">20</span>);
factorial(<span class="hljs-number">0</span>);
</code></pre>
<p>The function <code>factorial()</code> crashes or slows down the browser because the ‌‌stack space, that is the memory the browser allocates to the function call chain, is used up. The error, in this case, is a resource error because it occurs as a result of using up the allocated memory (resources).</p>
<h4 id="heading-5-interface-errors">5. Interface Errors</h4>
<p>‌‌Sometimes we design program APIs to be used in certain ways but users use the programs differently and cause errors. Such errors are referred to as interface errors.</p>
<p>‌‌For example, let's say that the method <code>go(string)</code> expects a string but we call it with a number instead. That will lead to an error if the creator of the program doesn't expect and manage how the program should respond in such a case.</p>
<p>‌‌Most things in software follow standards. If your defined standards are not followed, you need to provide your users with error messages or guides to help them figure out they are using the application wrongly.</p>
<p>Documenting your APIs can help a lot in this case.</p>
<h3 id="heading-makes-sure-your-setups-are-suitable-for-your-tools">💥 Makes sure your setups are suitable for your tools</h3>
<p>It is important to have a setup that is suitable for your tools. Sometimes, your OS may not be compatible with your applications – maybe because it requires a newer version of the OS or it requires a certain software.</p>
<p>For example, WampServer may not run properly on Windows OS if some Microsoft VC runtimes are missing on the computer. Similar things can also happen with Linux and macOS.</p>
<p>You just have to be sure your setup is suitable for whatever you do.</p>
<h3 id="heading-be-deterministic-about-the-functions-of-your-program">💥 Be deterministic about the functions of your program</h3>
<blockquote>
<p>‌‌"In mathematics, computer science and physics, a deterministic system is a system in which no‌‌ randomness is involved in the development of future states of the system.  </p>
<p>A deterministic‌‌ model will thus always produce the same output from a given starting condition or initial state." - <a target="_blank" href="https://en.m.wikipedia.org/wiki/Deterministic_system">Source</a></p>
</blockquote>
<p>‌‌Then, the question is, how do we make a deterministic program? ‌‌You have to be certain about the type of data that's acceptable in your program and reject any data that doesn't fit in.</p>
<p>‌‌In short, you need to take the expected data and reject unexpected data or notify your users about expected data.</p>
<h3 id="heading-dont-use-it-if-you-dont-understand-it">💥 Don't use it if you don't understand It</h3>
<p>‌‌One of the best ways to reduce the creation of bugs is to only use approaches, methods, and classes you understand. If you have to use any approach or style you don't understand, research it and be sure of what you are about to do before doing it.</p>
<p>‌‌It is easy to introduce unnecessary bugs to your application whenever you make use of things you don't understand.</p>
<h3 id="heading-learn-to-type-accurately">💥 Learn to type accurately</h3>
<p>Typing accurately is underrated, because programming is more about thinking than typing. But being accurate while typing may help you reduce some syntactic errors, type errors, or typos.</p>
<p>Many programming bugs are caused by simple typographical errors. Your ability to type accurately gives you an edge in reducing bugs.</p>
<h3 id="heading-watch-fellow-developers-while-debugging">💥 Watch fellow developers while debugging</h3>
<p>‌‌Another interesting way to improve your debugging skills is to watch fellow developers while they are debugging. It helps to see different debugging methods, especially through their lenses.</p>
<p>‌‌There will always be tools or approaches we don't know about or use for debugging.‌‌ Watching others gives us the chance to discover the tools or approaches we may not be aware of.</p>
<p>Or even if you are aware of those different approaches, you might not know why or how to use them.</p>
<p>‌‌Watching others can influence us to revisit these approaches and tools that may eventually improve our debugging skills.</p>
<h1 id="heading-what-is-debugging">What is Debugging?</h1>
<p>Debugging is at the core of programming, because it takes up the largest percentage of your time while coding.</p>
<p>There are three major phases involved in debugging:</p>
<ol>
<li>Finding bugs.</li>
<li>Analyzing and understanding why bugs occur.</li>
<li>Fixing or removing bugs.</li>
</ol>
<h3 id="heading-how-to-find-bugs">How to find bugs</h3>
<p>Finding bugs starts with understanding the error messages you see.</p>
<p>It goes without saying that an error message is a pointer to a bug. If you understand the error message, you can track down the location of the bug with precision.</p>
<p>But some errors can be tiring because they may not have explicit error messages. We just may not get an expected result.</p>
<p>To find bugs, you need to:</p>
<ul>
<li>Be clear about your expectations.</li>
<li>Check the results you get.</li>
<li>Compare your expectations and the actual result to see what is missing.</li>
</ul>
<p>You can use a debugger or other useful tools to find those errors fast.</p>
<p>You can then check different parts of your code against your assumptions and perform trial and error to find the bug.</p>
<h3 id="heading-how-to-understand-why-bugs-occur">How to Understand Why Bugs Occur</h3>
<p>‌‌After finding a bug, you need to figure out why the code is behaving the way it does. Doing this helps you build an efficient system.</p>
<p>‌‌Instead many developers will just google and use the answers they get directly from StackOverflow.</p>
<p>‌‌That is fine in certain circumstances, but it is better to understand the cause of a bug and why the solution works.</p>
<p>‌‌Understanding the cause of a bug is an important step on the path to fixing it or removing the bug.</p>
<h3 id="heading-how-to-fix-or-remove-bugs">How to Fix or Remove Bugs</h3>
<p>‌‌After finding and understanding the cause of a bug, we have to fix that bug. Sometimes, once you understand what the bug is, you'll simply find a solution without stress.</p>
<p>‌‌However, there are times when our understanding yields no solution no matter how hard we try.</p>
<p>‌‌Instead of wasting time, it is okay to Google the error message or whatever you feel is appropriate.</p>
<p>‌‌You can also ask another person because others tend to see things differently. They are neutral and that neutrality does help in fixing some bugs.</p>
<p>‌‌So, Google it!</p>
<p>‌‌Ask questions on StackOverflow, Twitter, or wherever you're connected to other developers.</p>
<p>‌‌It's okay! We all do those things a million times.</p>
<p>‌‌Fixing a worrisome bug always brings about great excitement. But don't get caught up too much in the excitement, as fixing a bug may cause another bug. So first make sure you have not introduced another issue to the program. That is why automated tests are important.</p>
<h1 id="heading-what-is-post-debugging">What is Post-debugging?</h1>
<p>"Post-debugging" is about anticipating unexpected bugs in programs you've already written.</p>
<p>It refers to all the mechanisms you might use to ensure that unknown bugs are easily tracked down or managed before they harm the system or company.</p>
<p>The question now is how do you do that? Well, with an error tracking system.</p>
<p>You should have an error tracking system in production so that you can easily discover bugs as they emerge after pushing your application to production.</p>
<p>There are a lot of error trackers out there and they are just a bit of googling away. But here are a few you can check out:</p>
<ul>
<li>www.sentry.io</li>
<li>www.honeybadger.io</li>
<li>www.pypi.org</li>
<li>www.airbrake.io</li>
<li>www.logrocket.com</li>
</ul>
<p>There are so many error trackers out there, you'll just have to research to discover what is best for you.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Debugging is a major skill that all software developers must cultivate. It is at the core of coding, and if you do it well, it can make you a better developer.</p>
<p>To be great at debugging, you must learn as much as you can about various debugging methods, many of which I've discussed here in this article.</p>
<p>It is time to be a great software developer and debugging can help you along the line.</p>
<p>Now, you only need to put everything into practice to be great at debugging and your software development skills will not be the same again. </p>
<h2 id="heading-about-the-author">About the author</h2>
<p><strong><a target="_blank" href="https://twitter.com/codingnninja">Ayobami</a></strong> loves writing history with software development and is currently helping those who are struggling to understand and build projects with JavaScript through <strong><a target="_blank" href="https://bit.ly/3o3TMyg">You Too Can Code</a></strong>.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ The Beginner's Guide to Bug Squashing: How to Use Your Debugger and other tools to find and fix bugs ]]>
                </title>
                <description>
                    <![CDATA[ As web developers, it often feels like we spend more time fixing bugs and trying to solve problems than we do writing code. In this guide we'll look at some common debugging techniques, so let's get stuck in. "Fail to prepare, prepare to fail" What b... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/the-beginner-bug-squashing-guide/</link>
                <guid isPermaLink="false">66c8c908e9e57963a5d82acc</guid>
                
                    <category>
                        <![CDATA[ 100DaysOfCode ]]>
                    </category>
                
                    <category>
                        <![CDATA[ beginner ]]>
                    </category>
                
                    <category>
                        <![CDATA[ beginners guide ]]>
                    </category>
                
                    <category>
                        <![CDATA[ bugs ]]>
                    </category>
                
                    <category>
                        <![CDATA[ debugging ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Junior developer  ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Chris Blakely ]]>
                </dc:creator>
                <pubDate>Thu, 05 Dec 2019 15:46:00 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2019/11/bug.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>As web developers, it often feels like we spend more time fixing bugs and trying to solve problems than we do writing code. In this guide we'll look at some common debugging techniques, so let's get stuck in.</p>
<h3 id="heading-fail-to-prepare-prepare-to-fail">"Fail to prepare, prepare to fail"</h3>
<p>What better way to start an article than with an old cliche! Bug's and issues are going to pop up. There is simply no way of getting away from this (sorry). With some simple planning, there are ways in which we can <em>minimize</em> the complexity and number of problems we face.</p>
<h2 id="heading-break-the-task-up-into-smaller-tasks">Break the task up into smaller tasks</h2>
<p>Now, I get it, we all like to get very excited and dive straight into our coding projects. The thing is, without some sort of plan we are creating problems for ourselves before we even start! </p>
<p>If I said to you, "you have to build a shopping list app", and you started coding straight away, what would happen? You would end up staring at a blinking cursor wondering how or what to do first, cursing my name under your breath for asking you to do such a task.</p>
<p>It's always easier to take a large problem and break it up into many smaller problems. For example, we can break the shopping list project into smaller tasks:  </p>
<ul>
<li>Create a form to add an item to the list</li>
<li>Allow a user to remove an item from the list</li>
<li>Display a total number of items in the list</li>
</ul>
<p>You can even break these tasks up into more detailed tasks. For example, for the first task in our list, our first, "little mini task" (should I trademark that term?) could be:</p>
<p>1) Create an input field to capture the item name</p>
<p>2) Create a button that calls a functions <code>addToList()</code> when clicked</p>
<p>3) Write logic within the <code>addToList()</code> function that adds the item to the list</p>
<p>And so on. You get the idea. I prefer breaking work up like this as it really makes me think about the problems I'll encounter <em>early</em> and the solutions (<a target="_blank" href="https://www.freecodecamp.org/news/a-walk-through-the-developer-thought-process/">I've written an in-depth article about this here</a>) before I've written any code. It also helps me understand what I'm trying to do, and puts me in the "zone". It's much easier to solve problems that arise when you understand what you are trying to achieve.</p>
<h2 id="heading-be-prepared-to-purge-your-code">Be prepared to purge your code</h2>
<p>To make an omelet, we have to break a few eggs. This means being prepared to completely re-write our code to get it working. </p>
<p>I bet you're thinking, "oh man, it took me days/weeks/millennia to get this far with my code, and now I have to delete it?!"  Um, yeah. Sometimes. Sorry. The reality with web development is that code will change all the time, for various reasons - bugs, code reviews, changes in requirements, boredom, etc.</p>
<p>Sometimes we feel so precious about our code and can't bear to delete it, that we try and overcome problems by trying to "fit a round peg into a square hole". We think "NOO! I can't possibly delete this method. It took me forever. There has got to be a way!" This mental block causes our own problems - because by simply rewriting what we currently have, we could find the solution to our problems.</p>
<p>Now that we're nice and prepared, let's look at what happens when things do go wrong.</p>
<h2 id="heading-error-messages-are-good">Error messages are good</h2>
<p>What's worse than seeing an error message when something goes wrong? Not seeing <em>any error message</em> when something goes wrong. Even though it's a daunting feeling to see a big red stack trace when we run our carefully crafted code, error messages are there to say "yeah, things are messed up right now, but here are some places you can look to start fixing it". </p>
<p>If we have a look at this example:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> animals;

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">addAnimal</span>(<span class="hljs-params"></span>)</span>{
    animals.push(<span class="hljs-string">'elephant'</span>);
}

addAnimal();
</code></pre>
<p>Now let's have a look at the error:</p>
<pre><code><span class="hljs-built_in">TypeError</span>: Cannot read property <span class="hljs-string">'push'</span> <span class="hljs-keyword">of</span> <span class="hljs-literal">undefined</span>
at addAnimal (https:<span class="hljs-comment">//vanilla.csb.app/src/index.js:8:11) </span>
at evaluate (https:<span class="hljs-comment">//vanilla.csb.app/src/index.js:11:1) </span>
at $n (https:<span class="hljs-comment">//codesandbox.io/static/js/sandbox.acff3316.js:1:148704)</span>
</code></pre><p>I've left out some of the stack trace as most of it is, well, gibberish. Depending on how your frontend project handles error messages, you may even see the error in your browser:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/11/Screenshot-2019-11-20-at-17.00.45.png" alt="Image" width="600" height="400" loading="lazy">
<em>Look at that beauty of an error!</em></p>
<p>The important parts of the stack trace are usually at the top - the message, the function, and the line number, and our browser shows us this as well. So the interpreter does it's best to tell us what's wrong. It's a shame it can't solve the problem for us, eh?</p>
<p>So, we've finished having our panic attack at seeing the error and have picked some information from the error message. If we break it down we can see this line:</p>
<pre><code>Cannot read property <span class="hljs-string">'push'</span> <span class="hljs-keyword">of</span> <span class="hljs-literal">undefined</span>
</code></pre><p>This usually means that there is a variable not defined or initialized somewhere. BUT WHERE?!?</p>
<p>If we continue reading the stack trace, we see the error occurs within the <code>addAnimal()</code> function. We can see that we are trying to push a new animal to an array - ah! I forgot to initialize the <code>animals</code> array. Doh! Our fixed code looks like this:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> animals = [];

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">addAnimal</span>(<span class="hljs-params"></span>) </span>{
    animals.push(<span class="hljs-string">"elephant"</span>);
}

addAnimal();
</code></pre>
<p>The error thrown in the browser will show you the problem quicker, but not all frontend projects will be configured to do this, and backend developers do not have this luxury.  This is why I recommend learning to read the stack trace.</p>
<h2 id="heading-to-defeat-the-bug-you-must-think-like-the-bug">To defeat the bug, you must think like the bug</h2>
<p>The stack trace gives you an idea of what the error is. Well, sometimes it does and sometimes it doesn't. What if you see an error message that looks more like cave glyphs than English? Or what if there is no error, but your code is simply not acting as you thought?</p>
<p>It's time to get the debugger out. Let's walk through another example. But first some context! </p>
<p>Mr. Bob CEO (who is a CEO, who would have thought?!) approaches you and says,</p>
<p>"Hey, I have an amazing idea for a product.</p>
<ul>
<li>I want a web app that allows the user to enter a number.</li>
<li>If the number is less than 5, the message should read "UNDER".</li>
<li>If the number is equal to or more than 5, the message should read "OVER".</li>
</ul>
<p>This is a million-dollar idea and I want you to build it for me".</p>
<p>"OKAY!" You say, and you get to work. </p>
<p><strong><em><em>Coding montage with dramatic music plays as time fast forwards</em></em></strong></p>
<p>You've completed the code for your web app. Huzzah!</p>
<pre><code class="lang-html"><span class="hljs-meta">&lt;!doctype <span class="hljs-meta-keyword">html</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">html</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">"en"</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">"utf-8"</span>&gt;</span>

  <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>My super awesome number app<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"description"</span> <span class="hljs-attr">content</span>=<span class="hljs-string">"The HTML5 Herald"</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"author"</span> <span class="hljs-attr">content</span>=<span class="hljs-string">"SitePoint"</span>&gt;</span>

<span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"number-input"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">input</span>&gt;</span> <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"number-input-submit-button"</span>&gt;</span>Submit<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"number-display"</span>&gt;</span>0<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"./index.js"</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text/javascript"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
</code></pre>
<pre><code class="lang-javascript">(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">const</span> numberInputSubmitButton = <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">"number-input-submit-button"</span>)

    numberInputSubmitButton.addEventListener(<span class="hljs-string">"click"</span>, <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{

        <span class="hljs-keyword">const</span> numberInputValue = <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">"number-input"</span>).value;

        <span class="hljs-keyword">let</span> text;
        <span class="hljs-keyword">if</span>(numberInputValue &gt; <span class="hljs-number">5</span>) {
            text = <span class="hljs-string">"OVER"</span>;
        } <span class="hljs-keyword">else</span> {
            text = <span class="hljs-string">"UNDER"</span>;
        }

        <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">"number-display"</span>).innerHTML = text
    });
})();
</code></pre>
<p>(Note: You may have spotted the bug already. If you did, let's pretend you didn't. If you haven't noticed the bug, that's OK.)</p>
<p>Time to start testing. Let's run through some use cases for our business logic.</p>
<p>1) User enters 3:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/11/Screenshot-2019-11-20-at-17.18.36.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>2) User enters 7</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/11/Screenshot-2019-11-19-at-09.38.25.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>So far so good! But what happens if we enter 5?</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/11/Screenshot-2019-11-19-at-09.38.35.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>OH NO! A bug! The text displayed is incorrect, it should display "<strong>OVER</strong>" but instead displays "<strong>UNDER</strong>". Hmm, no error messages, and I can't seem to see in the code what is wrong. <strong>Let's run the debugger and step through the code.</strong></p>
<h3 id="heading-using-the-debugger">Using the debugger</h3>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/11/Screenshot-2019-11-19-at-09.39.41.png" alt="Image" width="600" height="400" loading="lazy">
<em>Note the "variables" panel on the left - this can be a life saver</em></p>
<p>A good place to start is to put a <strong>breakpoint as close to the buggy code as possible.</strong> You can determine this by reading the code, error messages, or if you have that "<em>ah-ha!</em> <em>I know which method is causing this</em>" moment. From here, it's a case of stepping through the code, inspecting the variables, and checking if the correct code branches are run. </p>
<p>In our example, I have put a breakpoint at the start of my <code>if statement</code> - as this is where the failing logic is.</p>
<p>Once I start debugging, chrome opens and I can replicate the issue by entering "5" and clicking submit. This hits the breakpoint, and immediately there are a few things to note:  </p>
<ul>
<li>The debugger stops at the breakpoint, so this means I'm on the right track</li>
<li>This also means that the function is being called correctly, and event handlers are working as expected</li>
<li>I can also see that the user input is being captured correctly (from the "variables" panel on the left-hand side, I can see that "5" was entered)</li>
</ul>
<p>So far so good, no immediate issues to worry about. Well, code related ones anyway. Next, I'll press <strong>F10 to step through the code</strong>. This runs each statement individually, allowing us to inspect elements, variables, and other things at our own pace. Isn't technology just fabulous? </p>
<p>Remember since I expect the message "OVER" to appear when the user enters "5", I'm expecting the debugger to take me into the first branch of the if statement...</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/11/Screenshot-2019-11-19-at-09.39.58.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>BUT NO! I'm brought into the second branch. Why? I need to amend the conditional to read "<strong>more than or equals to"</strong> as opposed to <strong>"more than".</strong></p>
<pre><code class="lang-javascript"><span class="hljs-keyword">if</span>(numberInputValue &gt;= <span class="hljs-number">5</span>) {
    text = <span class="hljs-string">"OVER"</span>;
} <span class="hljs-keyword">else</span> {
    text = <span class="hljs-string">"UNDER"</span>;
}
</code></pre>
<p>Success! Our bug is fixed. Hopefully this gives you an idea on how to walk through the code, making use of VSCodes awesome debugging tools.</p>
<h2 id="heading-more-debugging-tips">More Debugging tips</h2>
<ul>
<li>If your breakpoints aren't being hit, this could be part of the issue. Make sure the correct functions or event handlers are being called in the way you expect</li>
<li>You can <code>step over</code> functions you want to skip. If you want to debug any functions you come across, use the <code>step into</code> command</li>
<li>Watch out for variables, parameters, and arguments as you are stepping through your code. Are the values what you expect?</li>
<li>Write code in a way that is easier to read/debug. It might look cool to have your code on one line, but it makes debugging harder</li>
</ul>
<h3 id="heading-google-is-your-friend">Google is your friend</h3>
<p>Ok so we've looked at the stack-trace, tried debugging, and we're still stuck with this bug. The only thing left to do now is make a sacrifice to the coding gods and hope things fix themselves! </p>
<p>Or I guess we could use Google. </p>
<p>Google is a treasure trove of software development problems and solutions, all at our fingertips. It can be sneakily difficult to access this information though, as you have to know how to Google the right things to get the right information! So how do we effectively use Google?</p>
<p>Let's look back to our first example - you've read the stack trace, looked at the code, but the message <code>Cannot read property 'push' of undefined</code> is still driving you mad. Bewildered, you take to Google in hopes of finding an answer. Here are some things to try:</p>
<p><strong>Copy and paste the error message.</strong> Sometimes this works, depending on how "generic" the error message is. For example, if you get a <strong>Null pointer exception</strong> (who doesn't love those?), Googling "Null pointer exception" might not return very helpful results.</p>
<p><strong>Search for what you are trying to do.</strong> For example, <em>"How to create an array and add an item to the end"</em>. You might find some generous developer has posted a solution using best practices on StackOverflow, for example. You might also find this solution is completely different from yours - remember what I said about being comfortable purging your code? </p>
<p>A side note on using someone else's code - try and avoid blindly copying and pasting, make sure you understand what the code does first!</p>
<h3 id="heading-ask-for-help-the-right-way">Ask for help the right way</h3>
<p>Hopefully, after a mix of debugging, stack trace investigating, and Googling you have seen the light at the end of the tunnel and solved your problem. Unfortunately, depending on what you are trying to do, you still might be a bit stumped. This is a good time to seek advice from other people. </p>
<p>Now, before you run into the street screaming "my code is broken please help me!", it's important to know the best way to ask for help. Asking for help in the right way makes it easier for people to understand the problem and help you solve it. Let's look at some examples:</p>
<p><strong>Bad</strong> - "My code is broken and I don't know what's wrong."</p>
<p><strong>Good</strong> - "I'm trying to add an item to the end of an array in JavaScript, and I'm getting this error message: Cannot read property 'push' of undefined. Here's my code so far."</p>
<p>See how the "Good" example is much more informative? More information makes it easier for other kindhearted devs to help you out. This is a good habit to get into as it not only benefits you when you are learning to code but also in your first job when you need to ask for help.</p>
<p>So where can you ask for help?  </p>
<ul>
<li>StackOverflow</li>
<li>Twitter</li>
<li>Slack groups</li>
<li>Colleagues or developer friends</li>
</ul>
<p>Quick Tip: You can use a tool like <a target="_blank" href="https://www.freecodecamp.org/news/the-beginner-bug-squashing-guide/codesandbox.io">CodeSandbox.io</a> or <a target="_blank" href="https://www.freecodecamp.org/news/the-beginner-bug-squashing-guide/codepen.io">CodePen.io</a> to recreate your problem and share it with people.</p>
<h3 id="heading-practice-practice-practice">Practice, practice, practice</h3>
<p>Just like Rome wasn't built in a day (well, it could have been for all I know) you will not become king bug squasher overnight. As your career goes on and your experience grows, you'll be armed with a wealth of knowledge that helps you solve bugs and issues faster. I regularly find myself saying "ah, I've solved that before" or "oh yeah, I have a StackOverflow link that helps me here" and the whole thing becomes a lot easier. So keep practicing, and this skill will grow naturally.</p>
<p>Thanks for reading! If you enjoyed this article, <a target="_blank" href="https://subscribe.chrisblakely.dev/">why not subscribe to my newsletter</a>? </p>
<p>Every week I send out a <strong>list of 10 things</strong> I think are worth sharing — my latest articles, tutorials, tips and interesting links for upcoming developers like you. I also give out some free stuff from time to time :) </p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ These common mistakes will lead to immortal bugs. Learn how to avoid them. ]]>
                </title>
                <description>
                    <![CDATA[ By David Yu Didn’t we already fix that? The question that you or your teammate would ask after the product manager posts a snapshot of the bug. This whole event feels like a Deja Vu. You try to retrace the time you fixed that bug in the commits, but ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/these-common-mistakes-will-lead-to-immortal-bugs-learn-how-to-avoid-them-eee79ee43cd5/</link>
                <guid isPermaLink="false">66c362f5020f8e9c31066e66</guid>
                
                    <category>
                        <![CDATA[ bugs ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Life Lesson ]]>
                    </category>
                
                    <category>
                        <![CDATA[ software development ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web Development ]]>
                    </category>
                
                    <category>
                        <![CDATA[ WeChat ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Tue, 13 Nov 2018 23:25:53 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/0*_tDOnN79K8WqoVD0" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By David Yu</p>
<p><strong><em>Didn’t we already fix that?</em></strong></p>
<p>The question that you or your teammate would ask after the product manager posts a snapshot of the bug.</p>
<p>This whole event feels like a Deja Vu. You try to retrace the time you fixed that bug in the commits, but what’s the point?</p>
<p>The reality is if you don’t get to the root cause of the bug, it will come back like the Hydra of Lerna.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/m8XUwZGMf2YTjk5zY2UhvOKC8qrJ2D5JEkIA" alt="Image" width="800" height="562" loading="lazy">
_Source: [Wikimedia Commons](https://commons.wikimedia.org/wiki/File:Hercules_and_the_Hydra_of_Lerna-_Hercules_grasps_his_club_with_both_hands_and_confronts_the_seven-headed_hydra,_from_the<em>series</em>%27The_Labors_of_Hercules%27_MET_DP832529.jpg" rel="noopener" target="<em>blank" title=")</em></p>
<p>Here are some patterns that lead to immortal bugs.</p>
<h3 id="heading-hardcoding-a-value">Hardcoding a value</h3>
<p>When we’re doing front-end development, we often use dummy data to build out the user interface quickly. That’s fine.</p>
<p>The problem is having dummy data at multiple locations. Then it’s easy to forget one or two when you push your code.</p>
<p>Here are some tips:</p>
<ul>
<li>Use a single variable for your dummy data and share it across different components</li>
<li>Write a comment like <code>// TODO: remove later</code> to allow easy search later</li>
<li>Don’t rely on backend data to always be the same</li>
</ul>
<pre><code><span class="hljs-comment">// ?</span>
</code></pre><pre><code>&lt;img src={<span class="hljs-built_in">require</span>(<span class="hljs-string">`./assets/<span class="hljs-subst">${backendData.fileName}</span>.png`</span>)} /&gt;
</code></pre><pre><code><span class="hljs-comment">// This will break if fileName is an unexpected string</span>
</code></pre><pre><code><span class="hljs-comment">// ?</span>
</code></pre><pre><code><span class="hljs-keyword">let</span> img;
</code></pre><pre><code><span class="hljs-keyword">try</span> {
</code></pre><pre><code>  img = <span class="hljs-built_in">require</span>(<span class="hljs-string">`./assets/<span class="hljs-subst">${backendData.fileName}</span>.png`</span>)
</code></pre><pre><code>} <span class="hljs-keyword">catch</span>(e) {  <span class="hljs-comment">// Catch error if file doesn't exist</span>
</code></pre><pre><code>}&lt;img src={img} /&gt;
</code></pre><pre><code><span class="hljs-comment">// ?</span>
</code></pre><pre><code>&lt;img src={backendData.imgUrl} /&gt;
</code></pre><h3 id="heading-lets-refactor-later">Let’s Refactor Later</h3>
<p>Your codebase will only grow larger and larger as you work on it. Your client or your boss won’t know the negative effect of not refactoring the code, because everything looks fine on the surface.</p>
<p>Plus, it’s always more satisfying to write something new and show it to other people. “Hey, check out what it can do now.”</p>
<p>So how do we know when to refactor the code?</p>
<p>According to [Refactor Guru](http://2018-10-28    14:00    21:00    2018-10    ¥300.00    7:00:00    -¥2,100.00    David    Front-End    Bug fixes: speaker/headphone control. Countdown timer based on start_time plus duration. Update call status from in_progress to ended), follow the Rule of Three</p>
<ol>
<li>When you are doing something for the first time, just get it done.</li>
<li>When you are doing something similar for the second time, cringe at having to repeat but do the same thing anyway.</li>
<li>When you are doing something for the third time, start refactoring.</li>
</ol>
<h3 id="heading-keep-everything-in-one-file">Keep everything in one file</h3>
<p>This goes along with code refactor. When the project is fresh, it’s difficult to predict how large a feature will become.</p>
<p>In the past, I had a file that grew into thousands of lines of code. Refactoring that code is like performing surgery, delicate, but rewarding at the end.</p>
<p>Most people have a principle of how their project is structured. Separation of files by pages, features, dev. or production, private or public method, MVC model, etc.</p>
<p>How to structure a project folder is a large discussion by itself. I will save that for another article.</p>
<h3 id="heading-dont-write-specs-for-api">Don’t write specs for API</h3>
<p>“Wait, why don’t the pictures show up anymore?” the product manager asks the front-end developers.</p>
<p>“Wait, why doesn’t the data have the picture_url anymore?” The front-end developer checks the console for network response.</p>
<p>“Oh yea, now the pictures come in three sizes. large_pic_url, med_pic_url, small_pic_url.” The back-end developer heard the discussion and jumped in.</p>
<p>Sounds familiar?</p>
<p>Everyone is trying to do their job. But synergy won’t happen in the silo. It’s everyone’s job to communicate what’s needed.</p>
<p>Here are some simple solutions to start.</p>
<ul>
<li>Before building an API, start with a JSON file of the data that both front-end and back-end developers have access to.</li>
<li>When the API is completed, generate the document with <a target="_blank" href="https://github.com/apidoc/apidoc">https://github.com/apidoc/apidoc</a></li>
<li>Notify of breaking changes before deployment</li>
</ul>
<p>There are more sophisticated approaches to writing specs and handling documentation. And I would love to hear about what approach your team uses in the comment section.</p>
<h3 id="heading-merge-code-without-reading-conflicts">Merge code without reading conflicts</h3>
<p>Breaking things is less of a worry since you can always revert back to the previous commit.</p>
<p>It’s your or your teammate’s code disappearing during the process that’s the problem.</p>
<p>This often happens when you want to “save time” and move forward.</p>
<p>When in doubt, get in contact with the developer who made the commit that conflicts with yours.</p>
<p>When you mess up, <code>git merge --abort</code> or <code>git-reset --hard</code>.</p>
<p>When it breaks beyond repair, remove the project and clone it again.</p>
<p>Think twice when doing <code>git push -f</code>.</p>
<h3 id="heading-fix-a-reusable-component-without-testing">Fix a reusable component without testing</h3>
<p>Reusable components are the magical trick up every developer’s sleeve. Like when the client pitches you the wireframe that contains the same date picker across several pages.</p>
<p>In your mind, you think, “I am going to make an awesome date picker component. Write less code. Do more.”</p>
<p>A few months later, the client says, “I want the date picker in this page to explode with fireworks and on other pages, different kittens to represent months”. Now you need the date picker to be more dynamic than it was.</p>
<p>Then after you make the changes, you discover that fireworks are coming out of the kittens.</p>
<p>If you are on a larger team, you can defer quality assurance to a different team.</p>
<p>But if there is no such functionality in your organization, you will have to do a global search for your component’s name to see what your component affects.</p>
<p>Make a note to yourself of those files. Test those file visually and functionally depending on what they do.</p>
<h3 id="heading-anytime-you-say-its-fine-for-now">Anytime you say, “It’s fine for now”</h3>
<p>You know you will have to go back to it later. The key is “don’t forget”</p>
<p>When you decide between speed of development and stability of the software, we must be careful not to always put speed as a top priority. It’s similar to driving a car without ever checking the condition of the car.</p>
<p>You can decide a ratio between speed and quality assurance. Maybe it’s two speedy iterations and one quality assurance iteration, whichever makes sense for your team.</p>
<h3 id="heading-conclusion">Conclusion</h3>
<ul>
<li>Avoid hardcoding a value if you can. If you have to, leave a note for yourself.</li>
<li>Refactor when you’re doing the same thing for the third time.</li>
<li>Split code and refactor often</li>
<li>Front-end and back-end engineers must work together to agree on the data being passed around.</li>
<li>If merge conflicts does not make sense to you, double check with the person who wrote the commit.</li>
<li>When making changes to a reusable component, test for the location(s) where it’s being used.</li>
<li>Find a healthy balance between speed and quality for your team.</li>
</ul>
<h3 id="heading-while-were-here">While we’re here…</h3>
<p>If you want to reach the 1 billion users of WeChat, you have to understand it first. Here’s a <a target="_blank" href="https://pages.convertkit.com/b2469604dd/0c671fdd2d"><strong>free glossary</strong></a> to get started.</p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
