The Cult of Clean Code

A few days ago, I watched a senior developer spend 3 days refactoring a perfectly functional feature because the functions were “too long.” The code worked. Users were happy. Tests were green. But somewhere, Robert C. Martin’s ghost was apparently crying, so we had to fix it.

Spoiler alert: the refactored version introduced two bugs and made the codebase harder to understand. But hey, at least the functions were under 10 lines each, right?

The Clean Code Kool Aid

I get it. When you’re drowning in legacy spaghetti code at your first job, Clean Code feels like a life raft. Uncle Bob shows up with his commandments (“functions should do one thing,” “no comments,” “DRY everything”) and suddenly you have RULES. Structure. A way to feel superior in code reviews.

  • “Actually, this function violates SRP.”
  • “This comment is a code smell.”
  • “We should extract this into our own class.”

Congratulations, you’re now part of the problem.

Clean Code isn’t a book about programming. It’s a book about programming religion. And like all religions, it offers simple answers to complex questions, eternal truths in a chaotic universe, and a convenient way to divide the world into the righteous and the sinners.

The Abstraction Trap Is Real and It’s Killing Your Velocity

Here’s what they don’t tell you: DRY is a trap.

That’s right, I said it. Don’t Repeat Yourself has probably caused more damage to codebases than copy and paste ever did. Because here’s what happens in practice:

You see two functions that look similar. Clean Code sirens start blaring in your head. You extract a common abstraction. You add parameters to handle the slight differences. Then more parameters. Then a config object. Then a strategy pattern because you’re a Real Engineer™.

Six months later, someone needs to modify one of those original use cases. But now they can’t just change the code. They have to understand your beautiful abstraction, figure out which of the seventeen parameters to modify, hope they don’t break the other use cases, and pray the unit tests actually cover the edge cases.

Duplication is far cheaper than the wrong abstraction. This isn’t even controversial. Sandi Metz said it years ago. But Clean Code zealots keep building their elaborate houses of cards because Uncle Bob told them to.

Small Functions Are Not Automatically Better

“Functions should be 4 to 5 lines long,” says Uncle Bob.

Cool. Let me just split this perfectly readable 30 line function into six tiny functions with adorable names like validateUserInputAndReturnProcessedData() that you now have to jump between to understand what’s actually happening.

You know what’s easier to understand than six 5 line functions? One 30 line function that does ONE THING from start to finish. I can read it top to bottom. I don’t need an IDE with “go to definition” just to follow the logic. It’s right there.

But no, we have to make everything “clean” by fragmenting logic into microscopic pieces and pretending that extractUserData() calling validateUserData() calling processUserData() calling saveUserData() is somehow more maintainable than just doing those things in sequence.

Comments Aren’t Evil, Your Codebase Is Just Boring

“Good code doesn’t need comments” is the most cargo cult nonsense in the entire Clean Code canon.

Sure, getUserById(id) doesn’t need a comment explaining that it gets a user by ID. No kidding.

But you know what DOES need a comment? The gnarly bit of code that works around a weird API quirk. The regex that took you 2 hours to write. The business rule that doesn’t make sense until you know about the compliance requirement from 2019. The performance optimization that looks weird but saves 200ms per request.

Your code can explain WHAT it does. It cannot explain WHY you did it that way. That’s what comments are for.

Every time someone removes an “obvious” comment, they’re basically saying “I understand this right now, so everyone will understand it forever.” That’s not confidence, that’s hubris.

Uncle Bob Built a Brand, Not a Methodology

Let’s talk about the elephant in the room: Robert C. Martin is a businessman first and a thought leader second.

He’s got books to sell. Conference talks to give. Consulting gigs to book. Training courses to market. The entire Clean Code industrial complex is his brand, and that brand is worth a lot of money.

I’m not saying his advice is wrong because he profits from it. I’m saying we should maybe be a LITTLE skeptical when someone builds their entire career around being the authority on One True Way to write code.

Real talk: Uncle Bob hasn’t written production code at scale in decades. He’s not dealing with your microservices architecture, your NoSQL databases, your React state management, your Kubernetes configs. He’s writing Java examples in books and telling you how to be a “professional.”

And yet we treat his 15 year old opinions like they’re carved in stone.

The Real Problem: Pattern Matching Over Thinking

Here’s what actually happens when Clean Code becomes dogma:

Junior devs learn the rules. They apply them everywhere. They pattern match “long function equals bad” and “duplication equals bad” and “comments equal bad” without engaging their actual brains.

Code reviews turn into rule enforcement instead of knowledge sharing. “This violates SRP” becomes a thought terminating cliche. Nobody asks “is this actually a problem?” or “does this abstraction make sense?” They just enforce The Rules.

And god forbid you ship code that works but doesn’t follow the checklist. You’re not a Real Programmer™ yet. You need to read more Martin Fowler. Maybe take Uncle Bob’s course.

What Actually Matters

You want to know what makes good code? Here’s the secret that won’t make me any money:

Good code solves the problem correctly and can be modified by your team without making them want to quit.

That’s it. That’s the whole thing.

Sometimes that means small functions. Sometimes that means one big function. Sometimes that means duplication. Sometimes that means abstraction. Sometimes that means comments everywhere. Sometimes that means self documenting code.

It depends on your team, your domain, your constraints, and your timeline.

The developers I respect most aren’t the ones who can recite SOLID principles in their sleep. They’re the ones who can look at a problem and make pragmatic trade offs. They can write clever abstractions when they’re worth it and boring straightforward code when it’s not. They know when to refactor and when to ship.

They think instead of pattern matching.

Breaking Free

If you’re reading this and feeling attacked, good. That discomfort means you’re thinking critically, maybe for the first time in a while.

Try this: next time you’re about to refactor working code because it “violates a principle,” stop and ask yourself:

  • Is this causing actual problems right now?
  • Will this refactoring make the code easier to change in ways we actually need to change it?
  • Am I doing this because it matters or because I read it in a book?

And if someone tells you your code isn’t “clean enough,” ask them what problems it’s causing. Not theoretical problems. Actual problems. If they can’t articulate any, maybe it’s fine the way it is.

The Bottom Line

Clean Code sold you a lie: that good code is about following rules.

Good code is about understanding trade offs. It’s about context. It’s about knowing your team and your domain and making informed decisions, not performing rituals from a book.

Uncle Bob isn’t your friend. He’s a guy who wrote some books in the 2000s and built a profitable consulting empire around them. His advice might have been relevant for enterprise Java development 15 years ago. It might even be relevant for your specific situation today.

But it’s not gospel. It’s one guy’s opinion, filtered through his specific experiences and biases, packaged into a product.

You’re allowed to disagree. You’re allowed to think for yourself. You’re allowed to write code that works, even if it wouldn’t pass Uncle Bob’s code review.

In fact, I’d argue you’re better off doing exactly that.

Leave a Reply