Rub-A-Dub Rubber Duck: Don't be Afraid to Debug!

Video in TIB AV-Portal: Rub-A-Dub Rubber Duck: Don't be Afraid to Debug!

Formal Metadata

Rub-A-Dub Rubber Duck: Don't be Afraid to Debug!
Title of Series
Part Number
Number of Parts
CC Attribution - ShareAlike 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal and non-commercial purpose as long as the work is attributed to the author in the manner specified by the author or licensor and the work or content is shared also in adapted form only under the conditions of this license.
Release Date

Content Metadata

Subject Area
Everyone of us knows this scenario, it's part of the daily life of a programmer: You build something and it doesn’t work. You run into a bug, you find a problem, you break your code - and then you have to figure out how to fix it again. This can take 5 minutes, several hours, sometimes even several days. Sometimes you get really frustrated and are about to give up but when you finally find the solution it's the greatest feeling in the world. Do you want to learn how to proceed when your code doesn’t work? Do you want to learn how you can become a better problem solver? Do you want to learn how a rubber duck can help you? Then this talk is for you :) In this talk I will present strategies on how to proceed when you run into a bug or other coding problems. I will also talk about what you can do in order to prevent frustration and how you can learn to be more confident when encountering bugs. My goal is to show that bugs are nothing to be scared of, that you can fix (almost) everything and shouldn’t be afraid of breaking things, and that debugging can be easier than you think it might be if you approach it the right way. Breaking things is the first step to learning how to fix them! This talk is inspired by a blog post I wrote a while ago, which you can find here(). Introduction - Who am I? What is this talk about? (2 minutes) What is a bug?/What is debugging? (5 minutes) Why breaking things is great - Don’t be afraid to break things (3 minutes) Why a rubber duck? - Debugging strategies (10 minutes) Reading error messages the right way How Google can help Rubber ducks, hypothesis, testing different approaches/solutions Reproducing bugs Breaking your code down into smaller pieces Drawing diagrams of code/writing pseudocode Reading documentation Debugging tools like the django-debug toolbar What to do when frustration kicks in (3 minutes) Where/how to get help (2 minutes) Q&A (5 minutes)
Degree (graph theory) Medical imaging Group action Data management Computer animation Personal digital assistant Multiplication sign Telecommunication Projective plane Remote procedure call Open set Spacetime
Code Set (mathematics) Software bug
Type theory Word Computer animation Code Weight Data dictionary Software bug
Word Arithmetic mean Computer animation Computer programming Software bug
Point (geometry) Code Multiplication sign Real number Electronic mailing list Computer programming Computer icon Software bug Type theory Googol Computer animation Strategy game Different (Kate Ryan album) Computer hardware Error message
Point (geometry) Run time (program lifecycle phase) Computer file Code Multiplication sign Closed set Poisson-Klammer Real number Line (geometry) Computer programming Formal language Number Type theory Message passing Crash (computing) Computer animation Interpreter (computing) Electronic visual display Arrow of time Pattern language Error message Exception handling
Run time (program lifecycle phase) Identifiability Computer file Code Gender Division (mathematics) Food energy Number Type theory Computer animation output Pattern language Video game console Error message
Run time (program lifecycle phase) Computer file Block (periodic table) Code Multiplication sign Electronic mailing list Mereology Computer programming Number Type theory Programmer (hardware) Crash (computing) Word Computer animation Logic Operator (mathematics) Object (grammar) Freeware Error message Typprüfung Social class Exception handling
Server (computing) Arm Code Gender Software developer Source code Frustration Web browser Stack (abstract data type) Programmer (hardware) Mathematics Arithmetic mean Googol Computer animation Software Internetworking Right angle Quicksort Error message Resultant Buffer overflow
Gateway (telecommunications) Programmer (hardware) Word Multiplication sign Stack (abstract data type) Disk read-and-write head Food energy Buffer overflow Computer programming
Boss Corporation Code Order (biology) Disk read-and-write head Computer programming Hypothesis Twitter
Area Functional (mathematics) Computer file Block (periodic table) Code Content (media) Letterpress printing Sheaf (mathematics) Line (geometry) Mereology Computer programming Computer animation Statement (computer science) Diagram Error message
Code Gender Multiplication sign Poisson-Klammer Projective plane Interactive television Water vapor Line (geometry) Mereology Computer programming Software bug Backtracking Computer animation Different (Kate Ryan album) Personal digital assistant
Computer animation Multiplication sign Gender Software developer Core dump Neuroinformatik
Computer animation Integrated development environment Figurate number Neuroinformatik
Computer animation Integrated development environment
Code Multiplication sign Cellular automaton Binary code Sheaf (mathematics) Control flow Plastikkarte Online help Frustration Basis <Mathematik> Disk read-and-write head Graph coloring Neuroinformatik Number Twitter Programmer (hardware) Mathematics Computer animation YouTube Typprüfung
Code Gender Expert system Side channel attack Field (computer science) Twitter Medical imaging Word Computer animation Hash function Selectivity (electronic) Quicksort Local ring
Computer animation Confidence interval
Computer animation
don't know what it this is due to the images in this case so this is this is and this is how everyone I hope you had a great time a great
morning urogenic on US and thank you so much for attending my talk at the 1st time Philadelphia and I'm really excited to be here and it's my 2nd time that I get to be getting upon and really really excited as so and and I'm from Germany and I have a degree in english and Catholic theology some of you may have identified William Shakespeare and Pope Francis on my side and Pope Francis was actually Philadelphia not too long ago the so that about 2 years ago I got involved in Python and now work for Algeria on and Appendix project as a community manager this that's where can also involved in a few other volunteer related things I am doing a kind US communications chair and the former remember the k-support of directors I am Picon US Open Spaces chair and I am 1 of the leaders of the pay ladies remote group and today I'm here to further my
talk with the title rubber Deborah that don't be afraid to debug the they're not going to be all about where it acts as you might have seen the set of all rather that pond over here so you all to take a oviduct when you leave and let me say something 1st so this
is to be me when I encountered a bug in my code really frustrated and angry is me now FIL a ghost
targets for you hopefully you like a warrior and feel prepared and ready when you know how when you encounter bugs in your code and to not be frustrated and upset and stare at them anymore because really but I nothing to be scared of I I'm an
English major seller dictionaries all of the so let's 1st efforts that take a look at what back actually it's so when you type in the back into the Merriam-Webster dictionary you can you get all of these wonderful definitions but can be an infected German can be an institute enthusiastic prominent a crazy person then it can be it can still listening device the weight allowance for jockeys that's all interesting I did not know that the word but had so many definitions but unfortunately we're not interested in any of those today the when we're interested
in is this 1 a back the is that affect fault Florida affection or in other words if something causes your coat to work now we know when a bug is I what's actually debugging
to back means to make to remove mistakes from your program on simple words make work so we now that we have that figured out
but if there's 1 thing I want you to take away from this talk already said that I want you to take away that's breaking code is nothing to be scared of who have you Academy of low and how many of you have are beginners there and I guess there's a feud and people here to who have you at 1 point in their programming career have been scared of bugs or debugging a program that's pretty much everyone and and I hope that within the next 25 minutes you will learn breaking things that's pretty great because breaking brings gives us the opportunity to learn how to fix them again I'm Anatolia little secret most things encoding can be fixed the you may not be able to debug it yourself there's always someone who can help and if nothing else works soldiers do it over again I let me tell you will anecdote which has to do with this pictures so I love my mom she's techno that man-months very technically challenge that allow her and last year she broke the on off button on her PC she had pushed it and she has a certain way too far and she was like I don't know what to do with their you will hear a repaired for me and so I said mom I have no idea how to do this because I'm not a hardware person had never taken a PC apart but I figured well we don't really want to spend the money and have it repaired professionally and we don't have the time to do that you there and so what did I do I turned to my friend Google and Google how to take her PC apart and I took it apart and I fixed the on off button it's it's not a perfect solution you still have to press the can hard to turn it on that there was a year ago and it still works the so that was me dividing the real world pro problem and I found a solution that works for us it's not the perfect solution but it works and when you when you're coding you have to remember that sometimes you have to consider if you want the perfect solution if you just want any solution sometimes uh and any solution might work for the moment and then you can always go better go back and make it better next time we let's take a look at a few debugging
strategies that learn how a rubber ducks can help us and please keep in mind that this is not an exhaustive list of dividing strategies nor did I choose a very technical approach on purpose they wanted to keep this simple because this talk is aimed at beginners urges people who want to learn something different about debugging on I let's start with error messages actually and please note and error messages are pretty crucial to debugging an error messages and nothing to be scared of I remember when I started programming in Python inside an error message and icon so I was so scared because I had no idea how to read it I have no idea what was wrong and it was just very scary but once you start getting more into programming you will notice that error message is actually a very useful feature because they help you time they help you figure out what is wrong with your code you just have to learn how to read them and Python we have 3 types of error
messages the 1st type of the so called syntax errors and then a put up these flights on flight deck afterward so you can read of what the most likely the independent pointed out not because I'm going to run out of time probably on the syntax errors are basically errors in the Python language in Python will find these kind of errors as it passes the program before it executes the program so basically syntax errors are mistakes in Python like you would make grammatical mistakes in english for example yeah let's
look at a very simple example when I run this code and get the following error message the and you can see that the pastor repeat the line and displays an arrow pointing at the earliest point in the land where the error was detected at the Earth detected at the token preceding the arrow so you can see here that the arrows here at my closing brackets so we know that the error must appear after the closing bracket and Python also so smart to tell us which file and which line here occurs in signing this file their creatively example 1 up I and my program has 2 lines and Python fast the line there is in my number 1 so you have you know what is causing the error yes the we right I forget to add a colon and that is something that will happen all the time you just forget 1 simple letter is signed and it causes the program not to run correctly the and if you can't see anything like that if anything wrong in your code at the Python says by number 1 is wrong and he looks real line and there's nothing wrong sometimes a pattern interpreter is not always right so look if there's nothing wrong in that line look in the preceding lines of code the 2nd type of error messages are the so called runtime errors are exceptions these errors occurred when your program is syntactically correct which means that is free of syntax errors Python will part of the program and it'll be fine with it but then will execute the program and all start executing it because it finds that around here and it's an exception and went Python does that we call that the crashes that your program crashes let's look at some examples of runtime errors
so we have the division there 0 a a a pencil pattern this error because they're trying to divide 5 by 0 and that just doesn't work that 1st answer 0 division error then and Intel says so where the lot where the error occurs here is it just says st DA and which means standard input because the type in the code and the console and I didn't save a file and it tells us in my number 1 energy also tells us that the error occurred as a trace back
another type of runtime errors using as using an identifier which has not been identified so you can see that China due to plus gender pony and patterns as on a mirror the name general pony has not been defined the then we have
the performing operation and incompatible type so you can see we're trying to do 7 plus 7 and conferences type error why does this not words right the I and then we have to other types of common types of runtime errors when a list a dictionary or an object doesn't exist or were trying that at 2 m access the file which doesn't exist and whenever where as programmers we work with users all the time and we work we work with people on people make mistakes and sometimes you can predict that a certain per part of your program as yeah might cause errors so if you're accessing a file for example you might know the users going that in the wrong file the file might not exist you can prevent the program from crashing the by using a try an exact block so 1st the tri class is executed and uses prompted to enter a number here in my example and if no exception occurs the program will run but if an exception occurs which means that the user doesn't enter a number and enter something invalid the except class will run in our program will not crash we so you can see that I was prompted to enter a number and type in an i which is obviously not a number so then and instead of getting an error message and instead of my program crashing Python tells me sorry that was not about number because I told and accept clause that's what I would like from a user to see and then I was prompted to enter a number again entered number 3 this time which means that program I ran this time had entered my name my name again that would have done the same thing over and over and over again but it would not have crashed and that's the time
here is entirely the hot the hottest 1 to the back of the so called logical errors they occur when your program as free of syntax errors and free of runtime errors but there's something wrong and the logic of the program and you will have to find these errors but basically reviewing parts of your code because there won't be an error message so you kind of have to figure out how to solve this and I will tell you how the and this was just a
very brief introduction the error message that to error messages there's a whole science to it so I would recommend these 2 arms sources they're pretty big a friendly and they helped me a lot while preparing my talk so again I will put my that once speaker afterward so you can find them there OK so arms sometimes though you'll stumble across error messages and you still don't know what Python 1 so you just don't know what a strong so where programmers and what to programmers turn to when they don't know what works the so yes or Google the the and will can actually very helpful to you will that be conscious when using google because google can cost a lot of frustrations because Google will only work if you tell it very precisely what is wrong with your code sometimes copying and pasting code into Google network and you might be able to pull up just the right StackOverflow answers but it doesn't always work that way so the example I'm this is me explain to Google very poorly what the problem I made some changes to my code but I can't access my website on the Internet and I don't know why it's really frustrating please help me google this is me over exaggerating but you know and so you can see the result they get there not very helpful at all they don't even mention Django anywhere close these are the top 4 results and the mean do more better at least I get
results mention Django the and this is me being pretty precise gender can access development server and browser and you can see that I get for stack overflow results and the click through all of them and they were all actually pretty helpful so just keep in mind if you use Google you have to be pretty precise the and and another technique we're gonna talk about now is an which programmers whereby as the so called rubber duck debugging if you've never heard of it before you might think it's sort of crazy but Robert X can and should be really very helpful so these are
some ducks from the famous sandbar Lawrence Kansas irritating avocations and no and you can see that 1 of these 1 of them with me here so programmers Levin's wherever it acts and and here's how it works take forever that you said on your desk just like I did here and then
you basically explained the rabbit out what the problem was and the ideas by speaking out loud and kind of like forming of the energy the problem in your head you get an idea of what might be wrong with the problem and you might not always be with the with the program and you might not always be able to solve the problem yourself but at least you get a better idea you actually learn to phrase what your problem as or you might it might be able to help you google what the problem is so the idea is to put it in more precise words the and other times river that debugging wall leads you to a solution of so that's when you can turn a stack overflow or Google or accuracy and various fact channels another gateway to develop
programs to come up with different hypotheses if you look at your code and you just set of 1 2 3 hypotheses on what could be wrong with the code and then you start going through them and verifying of falsifying them just write it down because the people like all in your head then you might get confused so actually take a piece of paper and write down your ideas yeah yeah I I that
I the and as I said before it you can take the oviduct home with you later my boss was who is not here today because is very sick but he was generous to let the order all of this x for you so you can take 1 home leader and we have 2 100 of them so please take 2 3 and please tweet pictures of your Robert axle of seeing pictures of Robert Ehrlich so take 1 home and entreaty pictures the and what's also
helpful is breaking your code down into blocks so we have of functions for example and you break down your code and into self containing blocks and then you comment them out and then you can see all this section is OK it's not causing the error but then the other section might cause the error and what's also helpful is when you write code right 10 and 20 lines of code and then put in a print statement and run the code and see if that works and that that's causing an error you know it's probably within the last 10 or 20 lines of code you just wrote it that's not passing an error the next 10 and 20 lines and you covering an area that I'm and repeat that if nothing else works if you have a program running let's say you have lot of file of like 50 lines of code to try and open up a new an empty file copy and paste lines of code from the existing program into the new program and just I just helps being organized and trying to debug the program that way very breaking it into smaller chunks of code it's much easier to about 10 lines of content to than to look through thousand lines of code I the the commenting out parts of coder
writing pseudocode can also be very helpful especially if you're working with code that is not your own just go through the code and try to translate code into English by whatever your own mother tongue as just make sure you understand what the code is doing how it is how it is executed draw diagrams and
how do different parts of code interact with each other how are they executed in which water just try to understand your program which will help you debug it so when you're following a tutorial I or documentation and you run into but there are 2 possibilities either you made a mistake or there is a mistake in the tutorial so you're going through the general gustatorial any other gender tutorial on just ask yourself these questions when you encounter about is the indentation corrected you forget any income the brackets are there any typos or did you leave out a whole line of code actually that happens all the time if you're not copying and pasting code but actually typing and you'll step out really early and by the way when you do a tutorial I would highly recommend actually typing the code yourself and not copying and pasting and after you double check
and you're absolutely sure that he did not make a mistake I would highly encourage you to check if the documentation and tutorials 7 get higher and that this go through the issues and see if someone else reported that Bach and that they did and then you know that the bug in the tutorial it's not something you didn't and that's not not I would highly encourage you to report that it's you and if it ends up not being an issue at all some from the person will tell you that but that's not an issue but they may be able to help you find the solution but if it if it if it is an issue and you actually helped a lot of people by reporting and in the case of Django you would go to code the genome project that common reported and the Django backtrack erect creating a new ticket
now you may have heard people talk about
reproducing but for a long time I honestly have no idea what reproducing like this and they and thank
you so I have to your quarterback and Django differently jingle core developer other gender developer will go in the room if you do this and this and this they will locate urea and back and they will try reproduce it and on their own computer and their own development
environment and the way they do that as the 1 in figure out is really about GenGO but does it have something to do with this set up with the computer or something like that and that's
actually pretty smart because of it's not about in general then we don't need to go ahead and try to
fix something that really does not he does not need to be fixed and if you're debugging something trying and if you've been doing
it for a long time try and ask a friend hey can you reproduce that book for me in your own development environment on your computer and if they can reproduce that then
you know it's actually but in something else and that they
can produce it and you know it has something to do with set of and while the reproduced grab while the reproduce that they will have to go through the same
steps you took encountering the back and they may actually be able to help you figure out which that
you got wrong the yeah on the
yeah it the the the we so this approach approaches I talked about air pretty hands on they're not very scientific on but there's also tools that you can use it that will help you do but others smart people wrote the generative but to bar the PDB what high-placed Pilon type-checker at 8 cell and there's other tools to so if you I wanna take a less hands-on approach please feel free to check this out I don't know I did mention them because they wanted to those wanted to follow a simpler approach but I just wanted to make you aware that they're there no there's an code and debugging can be very frustrating and it's not a nice emotion to be frustrated by all the time as I saw on Twitter while ago someone said well writing code you feel like a king or queen 1 day and you feel like an absolute failure the other day when we when your code just doesn't work but how do you deal with frustration and a healthy where we all programmers we deal with with frustration on a daily basis and like Patrick here we don't wanna start all over and math books so obviously everyone is different but the few things that you can do that help me 1st of all I would like to recommend that you us for help after a certain amount of time don't try and about the kind of 5 hours at a time because you probably won't find the solution and you will just get more and more frustrated just um trying to debug at for 30 minutes and if you can't do it try to ask someone for help step away from the computer for well taken that go for a walk go to your happy place and color and a coloring book that's what I do just do something different from or a lot of times I go to bed and get a good night's sleep and I wake up in the morning and the solution popped into my head magically D maybe you know the feeling when you stare at your computer for a while and you do not see the mistaken in you to give yourself a break on let someone else look at it and then you finally see what was wrong all along am a look for different solution if 1 person cannot help you really can't explain something in a very efficient way for you ask a different person I remember when added the code Academy Python Tutorial and there was a section binary numbers and actually did not get that concept at all and my friend tried explain it to me all nite and I still didn't understand that so then I found a short YouTube video it's human and YouTube video and afterwards the clip from these it wasn't that I was too stupid to understand binary numbers I just needed a different solutions that that happens you don't blame it on you on the person explaining it to you you just need a different and explanation and here's 1 thing I want you to remember you are
not the code you write code is just code and you're still wonderful person even if your code doesn't want 1 day so remember that take a sticky now infinite and you don't you're not because you're right you're not a failure you cut may feel that you're not a failure on you being not being able to debug your code may have a million reasons but it has nothing to do with you being stupid or any other issues you may have and if you can find a solution here is few things you can turn to that I already mentioned staggerer it's pretty that's a pretty great tool there some nasty people on there usually you can find a good solution but it is true and slapped romance and sort of selection channels there's no on we have such an offer Annex always happy to answer questions they're highly satisfactory imaging girls have a side channel you can turn to the gender girls get he goes you local meetups sentence Twitter can be very helpful don't be afraid to paying people on Twitter to just e-mail them especially if you know that they're an expert in the field you happier struggling with just turn to them for help and use the hash text path and Django on Twitter and when you can't find the words so I hope you'll do you
have to and and that's all I have for you today I won't be doing it you know because every fair chatting to people 1 on 1 but I'll be here all week so if you like to chat with me come see me now origin the next day search we meet at the lowest s in a 16 and I'd love to hear from you please all grab a rabbit out and don't
forget to grab a rubber exact and treated sumi I and had to put this and it uh I thought I was fine and now and don't bring other things take them
apart and that again effects and be confident and always remember that there's is a solution for everything they get a few but the thing is
the to you say
the even this was the