Sign in to follow this  

Clinical studies on overlooking stupid bugs

This topic is 669 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, does any of you know if there's ever been done some clinical/psyche studies on why programmers keep overlooking stupid errors in their code?

One example is the error I just found in my code:

while(some.function))
{
}

I should've easily seen that the open parenthesis was missing. Is there a special word for coding dyslexia? Like dyscriptia or something? And are there any known ways to reduce it and become better at spotting these things. I'm sometimes able to read through a line multiple times and still not spotting the error. So my solution is to go crazy and read the line letter by letter, which just seems a bit stupid.

Edited by Madolite

Share this post


Link to post
Share on other sites

It's not really specific to code or programmers. Have you never re-read a sentence you wrote several times without spotting a repeated article like "the the" or a missing word? Then you get someone else to read it and they spot it instantly, because they didn't write it so they don't "optimize away" the act of actually reading the sentence like you do because you already (believe you) know what's there and they don't.

 

One thing that I find helps is to add a generous amount of whitespace in your expressions, keep your lines short (not necessarily in terms of characters but in terms of information content) and not just cram everything into a tiny line full of symbols. For the rest, let the compiler check the syntax for you, and make sure that it can catch accessing undefined variables at compile-time or at least runtime with some kind of error. That should make sure that the syntax you write is approximately the syntax you had in mind.

 

I don't know about others but it's not rare for me to start coding something up, try and compile it 20-30 minutes later and spend a few seconds fixing a dozen little syntax errors or typos that I didn't catch (or didn't bother to) in my new code.

Share this post


Link to post
Share on other sites

QtCreator will show everything in purple that is covered by half-open bracket or parenthesis like that when the cursor touches the offending bracket.
It's very useful. See that "mMaxTexUnitReached( 0 ))" has no matching '(':
l9r11ye.png

Edit: I saw your other post. With practice you'll quickly learn to recognize that when your IDE's autoformatting is doing something you don't expect (like over- or under-indenting your lines), it probably means you've just introduced a syntax error.

Edited by Matias Goldberg

Share this post


Link to post
Share on other sites
I think most compilers have a warning setting to catch things like
if (x);
{
	y;
}
Maybe turn up your warning level? Or use some static code checking tool, like PVS-Studio or Cppcheck.

The compiler find most of my mistakes like this. The worrying time is when it compiles successfully and you know you're missing something, but can't remember what :-)

Share this post


Link to post
Share on other sites
Its is not just a programmers problem. And if you have too many errors you always seem too overlook its really about learning to write things in a way so you see the mistakes earlier.

But this problem is getting less I think as the IDEs get better and better.

Share this post


Link to post
Share on other sites

I am not a skilled programmer but to answer the OPs question, coders don't always do this because they are being lazy. Also I think we should be clear that syntax mistyping is very different from a bug in the coding world. These are just my definitions your mileage may vary :) :

 

Bug: A programming error that causes an outright failure of code or a failure of code to produce the expected results.

 

Syntax Errors: Mistyping code so that it does not function or compile.

 

Again just my 2 cents your mileage may vary :)

 

Anyways from my amateur programming perspective I have seen coders trying to hammer through an idea of concept they have and they are typing 100 miles an hour and end up with typos or syntax sloppiness that then takes from minutes to hours to resolve. My experience has been this, work in a powerful IDE. Something that highlights the obvious. The second thing to consider with these "bugs" is the alternative to hammering out great ideas in a hurry which is NOT getting things done. In software development piling bugs upon bugs upon bugs seems like madness but... infact there is a word for this kind of strategy in the development lifecycle and that is call "Agile". Agile is a project style that involves quick execution of small pieces of work and being willing to accept a certain amount of broken. The broken parts are flagged for fixing but potentially by someone more junior or a cheaper $/hr resource that allows the primary coders to stay focussed on the hard bits.

 

I think I am just rambling now but I wanted to respond to this because it used to drive me nuts until I took some courses in the Agile methodology for project management and realized that if you apply the right methods of handling the bugs and keep delivering slow but steady advances in your project you can cut down the time of delivery for a piece of software by massive amounts.

 

Anyways my .02$ good luck!

Share this post


Link to post
Share on other sites

This topic is 669 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this