Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Dumb mistakes that are caught immediately are not a problem. The figure that I've heard is that on average 1 line in 10 of code as initially typed has a mistake of some sort. That figure isn't unique to programming - it seems to be a fairly standard cognitive failure rate in humans that shows up in everything from errors made in formulas in spreadsheets to typos while writing. And it isn't a problem if most of the time you catch the error almost immediately. (For a similar phenomena think about how often you hit backspace while you're typing.)

The problem seems to be innate. To the best of my knowledge, you can't really reduce the rate of initial errors. Therefore you need to focus on how you catch errors. People have offered a number of suggestions. There are tools. People have mentioned strict.pm and syntax highlighting. There are programming strategies to give you additional cognitive cues. Things like making boolean variables be given names that are yes/no questions which the value is an answer to. The book Code Complete 2 has a lot of very valuable advice on that. There are practices like having good unit tests. And then there is the simple experience of having seen and caught certain mistakes so often that you're just on the lookout for them.

Now there is a funny phenomena. Which is that once you adopt strategies to correct these errors, the frequency with which you make them tends to go up! Why? Well it is because there is a lot that you have to think about during programming. As you get better, you devote less brain power to catching your trivial errors before they are made, and more to keeping track of the "big picture". This is actually a good thing. You see by adopting practices that immediately capture the trivial errors you make them utterly harmless. And the extra attention on the big picture results in better designs, better approaches, better code, and fewer of the really serious errors that could cost you a lot in the long run.

And one of the big picture items to keep track of is your sleep. It is sad, but one of the first things that goes when our mental functioning is impaired is our ability to judge how impaired we are. Which means that when you impair yourself, for instance by sleeping too little, you have no real monitor of how badly impaired you are. And the effects of lack of sleep are pretty serious, particularly for programmers. If you're noticing it, you need more sleep, then trust me, you would benefit a lot from having it.


In reply to Re: Avoiding silly programming mistakes by tilly
in thread Avoiding silly programming mistakes by missingthepoint

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: (7)
As of 2024-03-28 12:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found