Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Didn't we do a debugging thread here a while back? Might be worth it to check.

In any event, I think the most important thing I learned in my 28 years of programming is "debugging is hard". So I spend nearly every moment of my time while I'm programming thinking about how not to put bugs in in the first place, or at least have a pretty good idea what I just broke on the last edit cycle.

My methodology is basically:

  1. Start with an empty file.
  2. Write a dozen lines of code
  3. Run it
  4. If that doesn't work, add a few warn statements until I see what I broke, and fix it.
  5. Add another dozen lines of code. Repeat.
The key seems to be small incremental progress. Note that this methodology works for command-line, CGI, and whatever. Always have a testable version that's no more than a dozen lines different from the one you're working on. Then you'll know your error is always within the last dozen lines of code you wrote.

Another element is "understand what you type". You should be able to have a complete mental model of every step of what you type. Yeah, it sounds so basic, but I'm amazed when I watch my students copy random lines of code into their program and then say "it didn't work". When I ask them what a particular line does, they say "I don't know". Gosh, how do they expect it to work then!?

So maybe the combined rule is "never type faster than you can understand". {grin}

-- Randal L. Schwartz, Perl hacker


In reply to Re: Are debugging skills atrophying? by merlyn
in thread Are debugging skills atrophying? by dws

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-04-20 03:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found