Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Do you see how you contradict your own argument and/or misunderstood the original point?

Let me see if I can better explain the point I was trying to make.

Unlike you I have come across many people who do use the debugger as a crutch and spend hours stepping through code aimlessly. I think we're both in agreement that this is bad (even if you've never seen the behaviour).

Like you I have also encountered people who waste a lot of time sprinkling print statements or similar around a bug that would have been quicker to track down with a debugger. I agree completely that this is bad, I'm just not entirely sure that immediately resorting to the debugger is the best solution.

I guess the problematic behaviour that I sometimes see could be characterised as Debugger As First Resort.

A lump of code does something unexpected. Developer cannot immediately see what caused the error by looking at the code. Developer drops into the debugger and steps through the code, spots error and fixes it. Problem solved?

Maybe.

The problem I've seen with developers who use debuggers like this is that it seems to encourage a narrow view of the code. With the extra context the debugger gives they can more easily see the problem so they forget the fact that initially they couldn't see the bug. The debugger becomes a tool than enables them to avoid the bigger issues of avoiding introducing bugs in the first place, and writing code that's easier to understand.

Rather than immediately dropping into the debugger I think a more healthy reaction to not being able to understand the code you've written is to go "Deity on a bike! I've no idea what that bugger does. Better make it simpler until I do understand it". If you get good at it then you will tend to use debuggers less and less since the bugs get more and more obvious.

And I still find that people who dislike debuggers are those who don't know how to use a debugger effectively. I like debuggers. I don't use them that often. But when I've used them, they were often invaluable.

I too like debuggers :-) I can use them effectively. It's just that I choose to use other techniques that I find more effective most of the time. tlm found it "inexplicable" that a developer would choose not to use a debugger - and that was the issue I was trying to address.

Avoiding the debugger shouldn't be like "writing Perl programs without ever using hashes". It should be more like writing a Perl program without using local. Most of the time you don't need it, but it's occasionally useful.

But the debugger is a powerful tool and there are a lot of people (in my experience, the majority of programmers) who have never learned how to use this tool well (or even at all).

Yes it is a powerful tool. I agree that some developers don't know how to use it well so they don't use it at all. However, if somebody has to use the debugger as often as they need to use hashes in Perl their time would be better spent learning ways to avoid adding bugs and increase code comprehension.

Rarely using a debugger is sometimes a sign that somebody has learned ways of writing less bugs.


In reply to Re^5: Interactive scripting with DB by adrianh
in thread Interactive scripting with debugger by tlm

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 scrutinizing the Monastery: (10)
As of 2024-04-19 09:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found