DEV Community

Cover image for How to write dirty code
Andreas Barbesgaard
Andreas Barbesgaard

Posted on

How to write dirty code

Are you sick of hearing about "clean code"?

Do you long for the good ol' days of cryptic variables, magical numbers, and code that looks like it was written by a very ambitious raccoon? Look no further!

Presenting: the ultimate guide to writing code that will make your colleagues cry and future you ask, “What in the world was I thinking?”

1. Use Incomprehensible Variable Names

Why settle for clear names like customerEmail or orderTotal when you can achieve peak confusion with x1 and totalStuff? The goal is simple: nobody (especially you) should be able to figure out what the variables mean in the future. Ambiguity is your friend.

Example: Let temp hold… something important. Or maybe not. That’s for others to figure out!

public class y
{
    public void x()
    {
        int x1 = 43;
        string y2 = "_,,_";
        var z3 = new List<int> { 1, 2, 3, 4, 5 };

        var yb = x1 + z3[1];  
        var x12 = ab(y2); 


        for (int i = 0; i < yb; i++)
        {
            tb(x12);
        }
    }
Enter fullscreen mode Exit fullscreen mode

2. Avoid Comments Like the Plague

Comments are for those who lack confidence in their code’s mystique.

You wanna be dirty... and mysterious!

If you insist on commenting, keep it ambiguous: something like

//wtf
or
// ?

Your code should be dirty!

Bonus Tip: If you absolutely must add comments, make sure they’re misleading or redundant, like // fetch data here in a line where no data is fetched. You know, like the stuff you get back from LLM's.

3. Embrace the One-Million-Line Method

Who needs small, readable functions? One method should handle everything: data fetching, processing, updating the UI, and maybe even making coffee. If a function is under 500 lines, it’s practically under 500 lines.
Functions are like money a higher number is better!

def ult():
    u = gtdb()  # "u" for usrp

    s = sorted(u, key=lambda x: x['n'])  
    svdb(s)  # Save sorted stuff
    ui(s)  # Update 
    eml(u)  # Send emails to u <3

    t = 0
    for x in s:
        t += scr(x)  # Totally obvious!

    sui(t) 

    import datetime
    if datetime.datetime.now().hour > 23:
        nlm()  # Yes
this)
    l(u, s, t)  # Log 
Enter fullscreen mode Exit fullscreen mode

4. Forget Reusability

Reusability is for quitters. Copy that chunk of code everywhere it’s needed and tweak each one slightly, making future bug fixing an exercise in patience and detective work. Refactoring? That’s just a waste of time.

Pro Tip: Reinventing the wheel each time you code something slightly different builds character and job security.

5. The Magic Number Mystery

Constants are for the weak.

You should Hard-code values everywhere.

6. Bug Fixing is for Amateurs

If something doesn’t work, it’s probably user error. Don’t waste time "fixing" bugs. Leave them there to be discovered later when they’re much harder to diagnose. The trick is to bury them so deep, not even Sherlock Holmes could track them down.

Bonus: If someone insists on a bug fix, sprinkle a few try-catch blocks around that silently ignore exceptions.

7. Tests are Overrated

Testing code is for people who don’t trust their own genius. Who has time to check if things work? Why even ask this question? It works on you computer right?

Pro Tip: If anyone dares mention unit tests, nod, smile.

Top comments (0)