DEV Community

Cover image for What Leads to Coding Mistakes?
dev.to 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 (11)

Collapse
 
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.

Collapse
 
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).

Collapse
 
programcrafter profile image
ProgramCrafter

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.
Collapse
 
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

Collapse
 
kurealnum profile image
Oscar

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!
Collapse
 
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.

Collapse
 
ads-bne profile image
ADS-BNE
  • 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
Collapse
 
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.

Collapse
 
ingosteinke profile image
Ingo Steinke, web developer

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

Collapse
 
piotroxp profile image
Piotr Słupski

1) Unrealistic deadlines that can't be moved
2) Developer Burnout
3) Middle management

Usually come all together leading to failure.

Collapse
 
lisichaviano profile image
Lisandra

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.