9 Ways to Write Bad Code


Bad code is everywhere. It’s made by people who have been in the industry for a long time, it’s made by people who have just started, and it’s made by people who are paid a lot of money to write it.

This blog is about bad code. We’re defining it here as bad practices in programming or, more specifically, in writing code. Not bad design, not bad project management, not bad testing, but bad code.

We’re going to look at 9 ways of writing bad code – some of which are very common in legacy systems. We’ll explore why they are bad, what you should do instead and how to fix the damage once you’ve encountered them.

There are many ways to write bad code. This blog is about bad code. We’re defining it here as bad practices in programming or, more specifically, in writing code. These are not personal attacks. The code is not bad because the programmer is dumb. The programmer may be smart and talented, but still writes bad code. Zen Master programmers are not immune to writing bad code.

Why write a blog on how to write bad code? To understand how to write good code, you have to understand what makes the bad stuff so terrible. So we’re going to look at some common mistakes programmers make when trying to solve a problem.

Writing bad code is easy. Writing good code is hard. It’s not that there’s some kind of mysterious, elusive quality to writing good code. It’s just a lot of little things done right.

In order to do those little things right, you need to know what they are and why it matters that you do them right. That’s what this article is about: the little things that make up bad programming practices.

Many of these practices have been around for decades or even longer. And yet they persist in modern-day software development shops because too many software developers don’t know any better, management doesn’t care enough to insist on better standards or, more often, because the people who should know better are too busy doing things the wrong way themselves to worry about whether the new guy knows how to do it right!!!

When coding, do you take into consideration whether your code is good or bad? What about whether it’s easy to understand? Do you try to write code that others can read and maintain?

If you answered yes, you’re on the right track. If not, now is a good time to start.

It’s not just for your own benefit. It’s for the benefit of others who will come along — maybe even you in the future — who’ll be tasked with making changes and enhancements to your work.

Good code can streamline the process of adding new features as well as fixing bugs that crop up down the line. Bad code makes both processes more difficult and, in some cases, practically impossible.

Poorly written code can affect performance and degrade user experience, resulting in developers having to rewrite sections of the program or even entire applications from scratch. This is not only time-consuming but costly, too.

If you want to avoid the pitfalls of bad programming practices and create code that reads like a beautiful story and stays that way over time, here are nine things you should avoid at all costs!

1. Misunderstand Code

2. Write Code that is Hard to Test

3. Code Without Refactoring

4. Don’t Write Comments

5. Write Code too Quickly

6. Write Code that is Hard to Read

7. Copy and Paste Code

8. Write Lots of Methods and Classes

9. Don’t Provide Enough Context

1. Construct long methods and functions

2. Nest code deeply

3. Use unstructured code constructs

4. Misuse global data

5. Duplicate code and data

6. Write unreadable code

7. Misuse memory and resources

8. Create software that’s impossible to test, debug, maintain, or extend

9. Provide insufficient comments

1. Write complex code

2. Use long methods

3. Violate standards

4. Duplicate code

5. Use magic numbers

6. Program by coincidence

7. Optimize early

8. Misuse design patterns

9. Don’t write unit tests


Leave a Reply

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