You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/templates/pages/learn/debugging.hbs
+26-26Lines changed: 26 additions & 26 deletions
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ slug: learn/
14
14
<divclass="attribution">
15
15
This tutorial was made by the Education Working Group, during the p5.js contributor conference at the Frank-Ratchye Studio for Creative Inquiry, Carnegie Mellon University in May of 2015. The contributors to this tutorial include <ahref="http://huah.net/jason/">Jason Alderman</a>, <ahref="http://tegabrain.com/">Tega Brain</a>, <ahref="http://taeyoonchoi.com/">Taeyoon Choi</a> and <ahref="http://luisaph.com/">Luisa Pereira</a>.
<imgsrc="{{assets}}/learn/debugging/0-0.jpg"alt="Black and white illustration containing the text 'a field guide to debugging!'"/>
18
18
19
19
<p>
20
20
This is a field guide for debugging for everyone—whether you are beginning to code or whether you have been coding for a long time, this guide breaks down the mysterious process of solving problems.
@@ -26,15 +26,15 @@ slug: learn/
26
26
<p>
27
27
A bug is a gap between what you think your system is doing, and what it is actually doing. <atarget="_blank"
28
28
href="https://vimeo.com/channels/debugging" >Clay Shirky aptly describes </a>a bug as "the moment when there is both a technical problem with your code as well as a problem with your mental picture of what is happening in your code." </p>
<imgsrc="{{assets}}/learn/debugging/0-1.jpg"alt="Two-panel black-and-white comic. First panel contains a person pointing at a mouse with the text, 'You think you moved the mouse to the circle.' Second panel contains a computer with a hand pointing to a mouse with the text, 'But the computer is actually giving instructions to move the mouse away from the circle.'" />
30
30
</p>
31
31
32
32
<p>You think you are telling the computer one thing, but it is doing something else. It may also be crashing or throwing errors. In order to close the gap, you must investigate. </p>
33
33
<p>When you are working on a project, you may play many different roles. You are an architect when designing and planning your program, an engineer when you are developing it. Then you will be an explorer, discovering the problems and errors and testing it in all the situations in which it needs to run. You are trying to find out where it might break. Finally, when debugging you are a detective, trying to figure out how and why things broke.</p>
<imgclass="small"src="{{assets}}/learn/debugging/0-3.png"alt="Illustration of an architect with a blueprint for a house looking at an open plot of land." />
35
+
<imgclass="small"src="{{assets}}/learn/debugging/0-4.png"alt="Illustration of an engineer lowering a roof onto a house." />
36
+
<imgclass="small"src="{{assets}}/learn/debugging/0-5.png"alt="Illustration of a person being surprised when the door to a house falls to the ground." />
37
+
<imgclass="small"src="{{assets}}/learn/debugging/0-6.png"alt="Illustration of a detective with a magnifying glass examining the house." />
38
38
39
39
<p>So how can you become a good detective and debug your program? Here are the ten steps that can help you become a good code sleuth. </p>
40
40
</div>
@@ -45,36 +45,36 @@ slug: learn/
45
45
<p>When you encounter a bug that you do not know how to solve, stop, pause and take a deep breath. Stand up, say hi to the dog, take a walk or if it's late go get some sleep. When you are frustrated, tired and upset, you are not in a good frame of mind to learn or solve a problem.</p>
46
46
<p>To find your errors you will need to change perspectives and become the detective. The goal is to find out what the program IS doing, rather than why it's not doing what it's supposed to. We need to get the computer to show us what it's doing.</p>
47
47
<p>The clues are in the values of variables and flow of program.</p>
<imgclass="small_center"src="{{assets}}/learn/debugging/1-0.jpg"alt="Illustration of a person with binoculars, with a speech bubble above their containing a fluctuating chart line." />
49
49
</div>
50
50
51
51
<h3class="start-element tutorial-btn"id="problem">2. Observe the problem </h3>
52
52
<divclass="info">
53
53
<p>Walk someone through the issue even if they themselves do not know how to program. If no one is around, draft an email explaining what you have done and breaking down what the problem is.</p>
<imgclass="med_center"src="{{assets}}/learn/debugging/2-1.png"alt="Illustration of a person typing their programming issue on a computer." />
55
55
<p>You probably won't need to actually send this email as often the act of writing it will help you to locate and identify what you need to do next. Some programmers have even been known to explain their problem to a friendly inanimate object like a rubber ducky.</p>
<imgclass="med_center"src="{{assets}}/learn/debugging/2-3.jpg"alt="Illustration of a person reviewing code printed on sheets of paper." />
62
62
</div>
63
63
64
64
<h3class="start-element tutorial-btn"id="start">3. Before you start... </h3>
65
65
<divclass="info">
66
66
<p>Before doing anything, save a copy of your code that you can go back to. While debugging you are likely to introduce other problems, break things or accidentally delete good work.</p>
<imgsrc="{{assets}}/learn/debugging/3-4.png"alt="Illustration of the text 'You can use git version control if you are a wizard!'" />
74
74
<p>Write a list of what you are trying, so you can keep track of what still needs to be checked. Be methodical, it will save you a lot of time in the long run.</p>
<imgclass="med_right"src="{{assets}}/learn/debugging/3-5.jpg"alt="Illustration of two people, one turning switches off and on and the other examining a series of lights connected to the switches." />
78
78
As you debug, you will be turning parts of your code on and off.
79
79
Every time you make a change, test your program. If you make multiple changes before testing, you will not know which change has what effect and are likely to break things further.
<imgsrc="{{assets}}/learn/debugging/4-1.png"alt="Two-panel comic strip. First panel contains a person saying, 'Why isn't my robot bringing me lemonade?' Second panel contains a person and a robot, the perseon saying, 'Oh. It's because I forgot to attach the left arm!' Text beneath the comic strip saying 'check your file dependencies.'" />
94
+
<imgsrc="{{assets}}/learn/debugging/4-2.png"alt="Two-panel comic strip. First panel contains a person on the phone saying, 'Why isn't my robot bringing me lemonade?' Second panel contains person and a robot, the person saying, 'Oh. It's because I was calling its office phone and not its mobile number!' Text beneath the comic strip saying 'Are you testing the right file?'" />
95
+
<imgsrc="{{assets}}/learn/debugging/4-3.png"alt="Two-panel comic strip. First panel contains a person with a remote controller saying, 'Why isn't my robot bringing me lemonade?' Second panel contains a robot, a person drinking lemonade, and a person with a remote controller saying 'Oh. It's because I was accidentally telling Erica's robot to deliver lemonade!' Text beneath the comic strip saying 'Are you editing/saving the correct file?'" />
96
96
</div>
97
97
98
98
<h3class="start-element tutorial-btn"id="blackboxes">5. Black boxes</h3>
99
99
<divclass="info">
100
100
<p>A black box describes any part of your system you do not understand the inner workings of. For example, a library or perhaps a function that you have not written for yourself. Systematically take out each black box one-by-one and run your program. This will help to see if these parts of the program contain the error.</p>
<imgclass="med_center"src="{{assets}}/learn/debugging/6-3.jpg"alt="Illustration of a person examining a console log." />
123
123
</p>
124
124
</div>
125
125
@@ -136,14 +136,14 @@ slug: learn/
136
136
<li>First chapter of Bocoup's and Rebecca Murphey's interactive textbook, <ahref="http://jqfundamentals.com/chapter/javascript-basics">jQuery Fundamentals</a>.</li>
137
137
<li><ahref="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide"> Mozilla's JavaScript Guide</a> and <ahref="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference ">JavaScript Reference </a>(this is really helpful for finding all of the built-in methods for, say a String).</li>
<imgclass="med_right"src="{{assets}}/learn/debugging/8-0.jpg"alt="Illustration of two people collaborating while working on computers." />
147
147
You can also ask people for help! They might be delighted to help you.
148
148
</p>
149
149
<p>
@@ -163,7 +163,7 @@ slug: learn/
163
163
</li>
164
164
</ul>
165
165
<p>ALSO: start with small problems! Do one thing at a time. It's ok to make smaller sketches to test one thing (draw a star! check twitter!) and then voltron them together into a bigger sketch (draw a star that turns red when you have a notification on twitter!)</p>
<imgclass="med_center"src="{{assets}}/learn/debugging/9-1.jpg"alt="Illustration of a person having a conversation with an anthropomorphized computer." />
167
167
</div>
168
168
169
169
<h3class="start-element tutorial-btn"id="resources">10. More resources </h3>
0 commit comments