Good way to Remove Bad codes

Adarsh gupta
3 min readJun 20, 2024


Improve Your Code by Avoiding These Common Antipatterns

Okay, let’s get this straight: Your code sucks. It’s a hard truth, but recognizing it is the first step toward improvement. Good choice.

But first, let’s define what bad code, or in layman’s terms, an antipattern, actually is.

If you want a video version of this code, check out this video

Bad code is code that leaves your entire team clueless about what it is or why it’s there. Writing good code isn’t about fancy syntax or impressive models; it’s about making it clean and clear — easy to understand for other programmers.

The simplest way to gauge the quality of your code is by counting the number of times you say “WTF” during a code review. In this blog, we will look into six antipatterns you should avoid while coding.

1. Spaghetti Code

Spaghetti Code is the most well-known antipattern. It is code with little to no structure.

It’s how most of us started coding: nothing modularized, random folder names, random file names, and an incomprehensible code flow. Maintaining such code becomes a nightmare. Quick fixes lead to big bugs down the line.

2. Golden Hammer

Just like if you have a hammer, everything you see is a nail. This antipattern occurs when you use the same solution for different problems.

For example, some developers use JavaScript for almost everything. TypeScript developers might assign the type as “any” to bypass type errors. This can cause performance issues because you’re forcing a square peg into a round hole.

3. Boat Anchor

The Boat Anchor antipattern occurs when programmers leave unnecessary code in the codebase, anticipating it might be needed later.

This often results from coding with hypothetical scenarios in mind. Developers add extra lines of code that are not immediately used, complicating debugging and wasting hours trying to understand why a piece of code exists.

4. God Object

God objects do too much. They set user IDs, handle transactions, send emails, calculate distances — you name it.

It’s like asking for a banana and getting it from a gorilla. You get what you asked for, but also a lot more. Remember: keep it simple, not stupid.

5. Onion Antipattern

This happens when developers create an overly complex and layered system that mirrors the capabilities of the existing platform. Instead of using built-in features, they add redundant layers, making the system unnecessarily complicated.

While it might offer a shortcut to introducing new features, it leaves you with unmaintainable layers of legacy code.

6. Copy-and-Paste Programming

Copy-and-paste programming is often seen in code reviews for junior developers or interns.

Lacking experience, they resort to applying code snippets from the internet without thoroughly testing or understanding their impact.

This can infect your source code with bugs from the original source, behaving like a virus that requires extensive bug fixes and modifications.


Thanks for checking this out. If you want the video version of this blog, check out the following video.



Adarsh gupta

Software Engineer | JavaScript developer | Technical Writer . Work with me? Connect with me?