5 ms·
How to debug small programs
- oneeyedpigeon 13y agothat link points to a google ad at the bottom of the page ...
- unwind 13y agoThis is great, both as actual content and advice to (beginner) programmers but also as "link-bait" in the best sense of the word, i.e. content that is very likely to gather a lot of inbound links. As a very active Stack Overflow user, I immediately start thinking about how many questions that are going to get links to this as comments. :) Well done, I hope it helps although I guess the supply of beginner programmers won't dry up over night.
- userbinator 13y agoThat is a rather long way of saying "figure out exactly what the program is doing, and whether it matches what you think it should be doing."
- moistgorilla 13y agoSome people need this sort of explanation.
- collyw 13y agoTurn on all compiler warnings. Read them carefully. I wish my end users would actually read the error messages at all.
- brudgers 13y agoThe degree to which it is acceptable to shit on students is a result of the prohibitions on laughter stackOverflow's moderators love. All the meanness and tribalism finds it's way oit and is vented upon the weakest members of the community. Yes, students can be rude asshats. But hang around 'regex' and asshattery is no more unusual than 'SML'. This article captures the smug prickishness that stackOverflow increasingly celebrates. JustFuckingGoogleIt was clever a decade ago. It's quick and to the point and the pain is over. Learning to program is hard. A non-working program with a looming deadline is genuinely and legitimacy stressful. And so what does the article do? It begins by belittling the student, telling them their question was not worthy of the great community. Let's be honest, the intended audience isn't students, its other StackOverflow contributors and its purpose isn't to teach but belittle. And that's the shame of it. A good article on debugging could be useful. Hell a teacher might even incorporate it into the class. But of course the StackOverflow community could not produce such a document. It violates their unfortunate tribal mores.
- MikeTaylor 13y ago"And that's the shame of it. A good article on debugging could be useful." This is a good article on debugging. It has a lot of specific, actionable, helpful advice. I can only assume you stopped reading after first couple of paragraphs.
- brudgers 13y agoIf I had stopped reading after a couple of paragraphs, I would not have been aware the article contained any "actionable advice." Likewise if I had stopped after 3 paragraphs or four or even five. It is only after six paragraphs of putting the student in their place - instead of just linking to StackOverflow's own prose describing good questions - that "First, turn on all compiler warnings" makes an appearance. Is this good advice? Not really. Manipulating compiler setting is a homework task in itself for a student. What could be simpler than setting compiler warnings? It's all right here: http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html However, there's a bit of a logical error in this method. [0] Apparently what a student is supposed to do after turning them on is return to stackOverflow and ask another question. Well at least the author recognizes that turning on compiler warnings isn't really progress toward debugging except in the sense that debugging consists of asking questions on StackOverflow. Yet in fairness, it is hard to call this bad advice to a student struggling to finish an assignment given the next piece of "helpful advice" is: "If your program still has a bug, obtain a rubber duck." The reason I struggle with this being better or worse than the first piece of advice is that at least rubber ducks don't make sport of trolling students with homework questions. [1] According to the article, obtaining a rubber duck will allow the student's code to compile. All that's left is to refactor, write some tests, and a specification. Wasn't that helpful? Someonw has already made and posted a video presentation of the method. [2] [0] OK, it's not really a logical error, it's just a way to keep the victims coming back for more. See next footnote. [1] http://codegolf.stackexchange.com/questions/16226/i-need-a-program-where-the-user-inputs-an-array-of-doubles-and-the-program-outpu http://codegolf.stackexchange.com/questions/16226/i-need-a-p... [2] https://www.youtube.com/watch?v=tNfGyIW7aHM https://www.youtube.com/watch?v=tNfGyIW7aHM
- ZoFreX 13y ago> StackOverflow is not about to debug your programs for you. Could not disagree more. Students: submit your homework to StackOverflow. You'll get yelled at, but someone will be desperate enough for imaginary internet points that they will give you an answer regardless (just make sure you keep your accept rate high enough). (NB: This is facetious. I don't condone submitting your homework to StackOverflow: You won't learn that way.)
- jwdunne 13y agoLOL you think this is bad and StackOverflow has it hard? I founded a number if groups on Facebook a few years ago and they're primarily a QA sort of community, like SO but purely on FB. We don't just get the "help me find the error questions" but also: - have u got free PDF for <expensive book> - please give me code for <trivial project> (often be explicit that its a student project) - what programming language should I learn? (Often its java or PHP. I literally know one guy who has been trying to decide for 3 fucking years) Sometimes I will get "I am just 2 gud at java coding" and also group/page spam. Sometimes questions like the above, especially the free pirated PDFs! Can't believe people would be rude enough to try and throw all my hard work over the years down the pan because they don't want to pay for education. I don't make money from this. Nor has it improved my career prospects. How dies StackOverflow sound now?
- brudgers 13y agoWhy the fuck should anyone at StackOverflow give a shit if, when, or how someone cheats on their homework? The answer is simple. Every building has a side where the dumpster goes. Crapping on students is StackOverflow's. Because it's the only officially sanctioned form of meanness on the site, that's where the venom flows. It is StackOverflow's culture which makes submitting homework questions a poor way to learn. Pair programming and mentoring are excellent pedagogical techniques. Homework questions don't reflect any more laziness than any other category of StackOverflow questions. Indeed it might be the case that fewer homework questions can be answered by Googling than questions about EMACS. I know, because I've answered both and homework questions tend to require solving a logical puzzle not just RTFM'ing. I learned a great deal from answering homework questions because that's about my level of expertise (just like Googling EMACS questions is). The internet points I earned are the same color as everyone else's - a shade of earnest helpfulness colored by the need to be loved. Students wind up at StackOverflow because that's where the search engines take them. A student can't avoid landing there as part of making an honest effort to solve the problem. Getting rid of students is simple, stop SEO and prohibit crawling bots. Notice how HN doesn't have a problem? The behaviour of StackOverflow's community toward students is simply a function of nothing better to serve as the other. It's the petty gatekeeping of a medieval guild. It has all the merit of kicking puppies. (This is facetious. I don't condone kicking puppies)
- mopedDreams 13y agoPrint("If you're reading this, that means the program got to this point!")
- cooper12 13y agoYep. This can be very useful. You could even print out the values of variables at certain points. It become less useful though as the output of the program increases, or as your program becomes more complex. that's when the things mentioned in the OP are helpful.
- cooper12 13y agoYep. This can be very useful. You could even print out the values of variables at certain points. It become less useful though as the output of the program increases, or as your program becomes more complex. that's when the things mentioned in the OP are helpful.
- cooper12 13y agoYep. This can be very useful. You could even print out the values of variables at certain points. It become less useful though as the output of the program increases, or as your program becomes more complex. that's when the things mentioned in the OP are helpful.