CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

View Poll Results: Were you taught how to debug code at college/university?

Voters
39. You may not vote on this poll
  • What's debugging?

    1 2.56%
  • No.

    17 43.59%
  • Some help was given.

    9 23.08%
  • Yes, it was part of the course.

    0 0%
  • Not applicable, self taught programmer

    12 30.77%
Page 2 of 5 FirstFirst 12345 LastLast
Results 16 to 30 of 64
  1. #16
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: Were you taught debugging

    Quote Originally Posted by Speedo View Post
    This is really a general attitude issue towards using computers/technology. For a great many people the train of thought goes something more like "Debug menu? What does this do? Hm, I don't know what it is, better leave it alone - might break something".
    http://www.xkcd.com/627/

  2. #17
    Join Date
    Jul 2002
    Location
    Portsmouth. United Kingdom
    Posts
    2,727

    Re: Were you taught debugging

    Quote Originally Posted by Arjay View Post
    You need another poll choice - something like:

    "Self taught programmer, but is proficient in debugging."
    I thought about that, but I was more interested to see whether it was taught formally, not having gone that route, being a self-taught coder.
    "It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong."
    Richard P. Feynman

  3. #18
    Join Date
    May 2009
    Posts
    2,413

    Re: Were you taught debugging

    Quote Originally Posted by JohnW@Wessex View Post
    Assuming you learnt programming in a formal situation, did debugging get taught in any significant way?
    There isn't much to teach about debugging is there? There's no special theory behind it or anything.

    It's much better to introduce tools of this kind as a natural part of the laboratory part of courses. For example in some basic programmming course you learn how to handle an editor and a debugger, in an electronics course you learn how to handle an oscilloscope, in a microprocessor course you learn how to handle a logic analyzer, in a biochemistry course you learn how to handle a PCR machine, in a type writing course you learn how to handle a coffee machine, etcetera.

    There are examples of cases where an "instrument" merits a course of its own but generally they're best introduced in the situation where they're naturally used. I'd say debuggers fall into this category.

    I would even go as far as to say that if the university/college you're considering is offering a course in program debugging you should have second thougths. This is a course you would rather expect at a vocational training centre.
    Last edited by nuzzle; September 7th, 2009 at 06:31 PM.

  4. #19
    Join Date
    Jul 2002
    Location
    Portsmouth. United Kingdom
    Posts
    2,727

    Re: Were you taught debugging

    Quote Originally Posted by nuzzle View Post
    There isn't much to teach about debugging is there? There's no special theory behind it or anything.
    The reason I posted this poll was because there are alot of people posting questions here who, while sometimes having a good grasp of the syntax of C++, often have no idea of the basic techniques available to debug their code.
    "It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong."
    Richard P. Feynman

  5. #20
    Join Date
    Apr 2007
    Location
    Mars NASA Station
    Posts
    1,436

    Re: Were you taught debugging

    attachment process work, how symbols are generated, how to analyze the stack, how to analyze core dumps, memory layout
    What is that ?
    Thanks for your help.

  6. #21
    Join Date
    Aug 2005
    Location
    San Diego, CA
    Posts
    1,054

    Lightbulb Re: Were you taught debugging

    Basic debugging seems like common sense to me. As John pointed out earlier the best way would be for the teacher to explain programming techniques during the class that will lead the programmer into learning how to use the debugger in the laboratory. I think that you could have part of a design course dedicated to error handling (including exception handling) / debugging. Unfortunately, during college I never really had a lot of guidance from the teacher. Then again, I went to school for engineering so computer programming was not really my major. I only really had a couple of classes on HOL programming. If I were a computer science major I would highly expect to take classes where debugging / error handling topics were covered in depth.

  7. #22
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: Were you taught debugging

    Quote Originally Posted by kempofighter View Post
    If I were a computer science major I would highly expect to take classes where debugging / error handling topics were covered in depth.
    Really, I'd expect that focus more in a software engineering major. Maybe in an introductory CS course.

    A CS major is more about learning algorithms and data structures and complexity theory and the like, than about the practicalities of coding. They pretty much assume you're going to figure that out on your own, especially if they aren't having you use an obscure language like Lisp or SML.

  8. #23
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    894

    Re: Were you taught debugging

    I answered no, even though my major in college was Computer Science. They showed us a quick way of building a debugger version in Visual Studio and briefly mentioned that we should not port our programs like that. The major push was toward learning the language itself (as in regards to c/C++/MFC.) So having all that knowledge in itself I would struggle a big time, like pretty much so many posters on this site do, as you have already noticed.

    I have to confess though that most of my debugging knowledge came from my previous "hobby". (And I feel really bad about it.) One of my friends back in college introduced me to SoftICE and to ways how to bypass a software registration by disassembling/debugging a program to find out the part where the "fix" had to be made. I know, it's bad, but I was stupid back then. (It was almost 10 years ago.) Now I can use that knowledge to not only safe-guard my own software and software of a company I work for, but it also helps me to better understand the debugging process. Here again, I'm not advocating people to go into hacking someone else's software, it's simply a weird way how I came to it.

    It also brings another point (which is, I guess, is an advanced debugging technique). Besides simply using a debugger and being able to place a breakpoint and catch a moment right before the "bug" happens, it is also important to be able to analyze the bug itself. In this case, what happened to be an indispensable asset for me, is the knowledge of the machine code and assembler. The Visual Studio has a less known feature (that is disabled by default) to not only see the source code but to also see a machine code for each line (called Toggle Disassembly, or Ctrl+F11). By seeing the disassembly for each line of code you can easily track down any hidden calls and registry/memory corruption that in a source code would appear as one line. That saved my butt many times.

    One more thing I want to add here, is that my way of designing software includes insertion of the ASSERT/VERIFY macros (for MFC) into as many functions/methods in my code as possible. They do checks on any possible erroneous situation, thus, in a way, by using them I'm preventing a possible need for debugging while writing the code. In this case, if an assertion fires I can pretty quickly trace it back to its origins since the whole source code is packed with other assertions (that didn't fire before this one) and thus that in itself provides me with the very moment when glitch occurred.

    Really quickly to illustrate what I mean:
    Code:
    //Say somewhere in a code, we need to read 'n' elements in the memory array 'pBuff',
    //starting with the index 'i', where 'sz' is the size of an array in array element count
    ASSERT(pBuff);    //Simple check that an array pointer is valid
    ASSERT(sz >= 0);     //Make sure size is correct
    ASSERT(i >= 0 && i < sz);   //Make sure index is valid
    ASSERT(n >= 0 && i + n <= sz);    //Make sure number of elements doesn't go out of scope
    
    ASSERT(!IsBadReadPtr(pBuff + i, n * sizeof(*pBuff)));      //Longer check -- use only if you get 'pBuff', 'i' and 'n' from outside of your program. In most cases it's an overkill to use this line
    
    //Reading itself may be necessary to include into an exception-safe block
    //All exception handling will stay in a Release build, unlike the ASSERTions.

    PS.
    Quote Originally Posted by JohnW@Wessex View Post
    Am I being a hopeless optimist in thinking that the "What's debugging" count will stay at zero?
    No so, hah
    Last edited by dc_2000; September 8th, 2009 at 09:35 PM. Reason: Addition

  9. #24
    Join Date
    May 2009
    Posts
    2,413

    Re: Were you taught debugging

    Quote Originally Posted by JohnW@Wessex View Post
    The reason I posted this poll was because there are alot of people posting questions here who, while sometimes having a good grasp of the syntax of C++, often have no idea of the basic techniques available to debug their code.
    I'm not at all sure a debugger is the right tool for the kinds of problems usually posted at this forum. Simple tracing seems good enougth to me.

    What I feel is generally lacking among posters is a program development methology. I was taught something called Stepwise Refinement. Somewhat simplified this means that you start with a small working program. Then you change it in small increments and make sure it still works after each change. In the end you have a big working program without having to debug anything.

  10. #25
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Were you taught debugging

    Quote Originally Posted by nuzzle View Post
    Somewhat simplified this means that you start with a small working program. Then you change it in small increments and make sure it still works after each change.
    There are many ways to verify it each time, what do you do?

  11. #26
    Join Date
    May 2009
    Posts
    2,413

    Re: Were you taught debugging

    Quote Originally Posted by Arjay View Post
    There are many ways to verify it each time, what do you do?
    I put in assertions and traces. The traces are temporary but the assertions stay.

  12. #27
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: Were you taught debugging

    For some types of programming that's good enough. For anything really math-heavy, especially research where the algorithm you're implementing may not be well-understood, I suspect it might not be.

    Of course as always, debugging is a combination of approaches used as appropriate. The debugger is only one of many options.

  13. #28
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Were you taught debugging

    Quote Originally Posted by Lindley View Post
    Of course as always, debugging is a combination of approaches used as appropriate. The debugger is only one of many options.
    I have a preferred list of debugging techiques. From most preferred to least preferred:

    Debugger
    Log File
    Event log
    Trace output
    Message box

    Blindly trying things hoping it will work is the worse.

  14. #29
    Join Date
    May 2009
    Posts
    2,413

    Re: Were you taught debugging

    Quote Originally Posted by Lindley View Post
    For some types of programming that's good enough. For anything really math-heavy, especially research where the algorithm you're implementing may not be well-understood, I suspect it might not be.
    Well I don't agree. Stepwise Refinement works whatever you're programming.

    I'm not saying you shouldn't use a debugger. I'm saying you should strive for having not to use one.

  15. #30
    Join Date
    Jan 2009
    Posts
    1,689

    Re: Were you taught debugging

    My list:
    Assert
    Log File
    Debugger
    Message box

    That's for big projects, for small projects, the log file is at the bottom, but Asserts are always on the top for me.

    I use the log file instead of the debugger so that I can program very quickly, once I've got it all written and it's working well, then I go back into the debugger and fine tune it, adding to the stability.
    Last edited by ninja9578; September 14th, 2009 at 06:37 PM.

Page 2 of 5 FirstFirst 12345 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured