#1
  1. It Doesn't Work!
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    Slovenia
    Posts
    112
    Rep Power
    11

    Debugging for a stupid person


    Please, look at my avatar and give me some pointers about debugging. :) Do I have to know the machine-level programming?
    I'm using Lcc-win32. Thanks.
  2. #2
  3. ASP.Net MVP
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Aug 2003
    Location
    WI
    Posts
    4,378
    Rep Power
    1510
    It's a science, and I mean that (most school call their programming degree "computer science"), so treat it as such. Use the scientific method. Every time you write a section of code, you make a hypothesis, or eductated guess, that if you write the code this way it will work the way you want it to. Then, you test the section repeatedly until you're sure it works according to the specifications for it, keeping in mind that any hypothesis has a good chance of being at least marginally wrong. As you find errors (bugs) in your hypothesis, you modify the code until repeated testing no longer finds any errors. Then you have a code "theory", or a piece that's ready for use in a larger program that may eventually be released for beta testing.

    All that is just a long way of saying it's basically trial and error.
    Primary Forum: .Net Development
    Holy cow, I'm now an ASP.Net MVP!

    [Moving to ASP.Net] | [.Net Dos and Don't for VB6 Programmers]

    http://twitter.com/jcoehoorn
  4. #3
  5. It Doesn't Work!
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    Slovenia
    Posts
    112
    Rep Power
    11
    Kewl. It will take 20 000 years for me. So I set the breakpoint and run the program.
  6. #4
  7. No Profile Picture
    status unknown
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    262
    Rep Power
    11

    Re: Debugging for a stupid person


    Originally posted by Loser
    Please, look at my avatar and give me some pointers about debugging. :) Do I have to know the machine-level programming?
    I'm using Lcc-win32. Thanks.
    In no particular order, except item 1:

    [1] Learn to use the debugger that comes with your programming environment. And learn how to use it well. This is one of the best investments of your time that you can make. (Simply, become proficient with the tools you're using).

    [2] Develop and test your code iteratively. Don't wait till you've written 250 lines before you start testing.

    [3] Use assert statements in development code.

    [4] Use simple output statements to assure yourself that program execution is as expected (better, though, is to use the debugger).

    [5] Write self-documenting code in the first place to make it easier to understand when you come back to debug it.

    [6] Test for functions returning error conditions or throwing exceptions in your code. e.g. Don't open a file and start reading/writing without checking first that it opened successfully.

    [7] Never assume that something can't happen. It will. The more certain you are that it can't, the more likely it is to happen.

    [8] Code for readability rather than efficiency. You can profile and optimise later if you need to.

    [9] When you get really stuck and nothing makes sense anymore take a break and do what normal people do for a few hours: play pool, have sex (on your own doesn't count), drink alcohol, eat pizza, watch TV, a little basket weaving. Even if it doesn't help, you can end up with an impressive collection of baskets. But seriously, taking a break is often more productive than cracking on, and be sure to take your mind off it completely.
  8. #5
  9. It Doesn't Work!
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    Slovenia
    Posts
    112
    Rep Power
    11

    Re: Re: Debugging for a stupid person


    [9] When you get really stuck and nothing makes sense anymore take a break and do what normal people do for a few hours: play pool, have sex (on your own doesn't count), drink alcohol, eat pizza, watch TV, a little basket weaving. Even if it doesn't help, you can end up with an impressive collection of baskets. But seriously, taking a break is often more productive than cracking on, and be sure to take your mind off it completely. [/B]
    That's true and it works. :)
    Thanks for the answer.
  10. #6
  11. not a fan of fascism (n00b)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Feb 2003
    Location
    ct
    Posts
    2,756
    Rep Power
    95

    Re: Re: Debugging for a stupid person


    Originally posted by BigBadBob
    In no particular order, except item 1:

    [2] Develop and test your code iteratively. Don't wait till you've written 250 lines before you start testing.
    ahh i m so glad i hear someone else say this, and a smart person at that! people used to always ask me why the hell i wil only write a small section of code and then recompile. but i think it makes much more sense to bite off small chunks, it makes isolating logic errors much easier.
  12. #7
  13. It Doesn't Work!
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    Slovenia
    Posts
    112
    Rep Power
    11
    I recompile my mini programs almost every sentence, +cos the programs I write are so small it recompile in 1-4 seconds.

    And you know what have i done? I debugged a program. And I enjoyed. Really enjoyed. It's just that pity there wasn't any error in the program, but in settings file... :D

IMN logo majestic logo threadwatch logo seochat tools logo