12 programming mistakes to avoid

Just as the art world is filled with wildly divergent opinions about what makes a great work of art, programmers often disagree upon what makes for great code, at least beyond the basic requirement that it shouldn’t crash.

Every developer has their own set of rules and guidelines. When a developer says not to do something, it’s probably because they did it once and failed badly. But new issues can arise when we overcompensate for a mistake by running in the opposite direction. Say your team dodges the x trap by choosing y instead, but it turns out that y has its own issues, leading to yet another long lost weekend.

The good news is, you can learn from both the original mistake and the overcompensation. The best path to nirvana is often the middle one. In this article, we look at some of the most common programming mistakes, as well as the dangers involved in doing the opposite.

Playing it fast and loose

Ignoring basics is one of the easiest ways to produce unstable, crash-prone code. Maybe this means ignoring how arbitrary user behavior could affect your program. Will the input of a zero find its way into a division operation? Will submitted text always be the right length? Are your date formats following the correct standard? Is the username verified against the database? The tiniest mistake can cause software to fail.

One way to solve this is to exploit the error catching features of the code. A developer who likes to play it fast and loose might wrap their entire stack with one big catch for all possible exceptions. They’ll just dump the error into a log file, return an error code, and let someone else deal with the mess. No sweat, right?

Obsessing over details

Some say that a good programmer is someone who looks both ways when crossing a one-way street. But, like playing it fast and loose, this tendency can backfire. Software that is overly buttoned up can slow your operations to a crawl. Checking a few null pointers may not make much difference, but some code is just a little too nervous, checking that the doors are locked again and again so that sleep never comes. No processing gets done in a system like this because the code gets lost in a labyrinth of verification and authentication.

Copyright © 2023 IDG Communications, Inc.

Source link

Leave a Reply

Your email address will not be published. Required fields are marked *