DEV Community

Cover image for What Leads to Coding Mistakes? staff for The DEV Team

Posted on

What Leads to Coding Mistakes?

What factors contribute to programmers making frequent mistakes? Are there specific habits or practices that tend to lead to errors in code?

Follow the DEVteam for more discussions and online camaraderie!

Top comments (10)

kaamkiya profile image
Kaamkiya • Edited

There are infinite thing that can cause errors, but some of the most common are ...

  • Not being on the same page as co-workers or other people on your team
  • Not understanding the codebase
  • Using C++
  • Writing unreadable code
  • Not commenting code
  • Using nondescript variable names (naming a variable hp instead of heightOfPerson, for example)

... and more.

thumbone profile image
Bernd Wechner

Tee hee, had to chuckle a little as part of me thinks that one source of errors is in fact the misapplication of ideas, like "infinite" (there most certainly is not an infinite source of errors I can assure you, not even almost).

programcrafter profile image

Let me continue with fairly more complex, but yet not uncommon reasons!

  • Overcertainty that input will have certain properties (often coupled with not having project structure in mind);
  • Trying to change existing code to do similar, but another, thing;
  • Writing functions with large amount of parameters of one type, then accidentally swapping them;
  • Separating logically connected variables into separate objects, then expecting them to be consistent.
skyloft7 profile image
Mohammed • Edited

Testing (or lack thereof).

It's super important to make sure that your code works for all inputs, valid or invalid (and handles them gracefully). For example, what if the math works out to a division by zero in a certain statement? Or if the file name itself has a '.' in it and now your code thinks the file extension is "InsertFileNameHere"?

Image description

adamdsherman profile image
  • Tech debt. Out of date code that prevents newer code from being implemented properly
  • Deadlines
  • Poor code review or QA practices
  • Late night and rushed releases
  • Lack of automated testing and linting applications
  • Poor documentation and communication between devs
  • Learning new tech
manchicken profile image
Mike Stemle • Edited

Time and staffing constraints are the root of all software quality evil. “Just get this done” is a great ethos for getting something, but it sucks at guaranteeing long-term satisfaction with what you got.

I’ve seen companies refuse to grant more time for testing, and then punish the team for releasing bugs.

It is far too much to ask developers to be perfect. AI won’t be perfect either.

thumbone profile image
Bernd Wechner

I'm tempted to take a step back and suggest the only real source of errors is human nature. The rest is detail including the details of trying reduce the likelihood and impact of errors and we have many methods for that, with a cost/benefit function that follows the standard Pareto curve (or 80/20 rule). When it's important, like a plane's control system, an x-ray machine, a banks back end) we can produce as good as failure free performance (as the curve is assymptotic and perfection an unattainable myth we can only ever push hard against the limits at great expense).

Where the consequences of errors are low and other features take priority (literally features or time to market for example) errors will be part of the product.

kurealnum profile image

A few things that come to mind:

  • Writing unreadable code
  • Poor variable names
  • Implementing something without understanding how it works

And finally, the bane of my existence...

  • Premature optimization!
ingosteinke profile image
Ingo Steinke

Blindly trusting tests, linters, and code assistance leads to coding mistakes?

lisichaviano profile image

There must be many reasons, but what comes to mind is, for example:

  • Not having linting tools configured in the projects
  • Not having implemented unit tests.
  • Copy and paste without reviewing.

Some comments may only be visible to logged-in visitors. Sign in to view all comments.