Skip to content
DevMeme
5234 of 7435
Clean Code's legacy: 25 functions to do the work of one
CodeQuality Post #5742, on Dec 16, 2023 in TG

Clean Code's legacy: 25 functions to do the work of one

Why is this CodeQuality meme funny?

Level 1: Puzzle Pieces Everywhere

Imagine you have a big picture that shows how to do a task, like a single page with all the instructions to bake a cake. It’s easy to follow because you can see everything at once. Now imagine someone cuts that one page of instructions into 25 little pieces and hides them in different places around the kitchen. 😵 You have to find piece #1 to read the first step, then walk over to find piece #2 for the next step, and so on. By the time you collect all 25 pieces, sure, you have all the instructions – but it was a lot of unnecessary work to get the full recipe! This is exactly the funny idea in the meme: sometimes it’s actually easier to understand something when it’s all in one clear chunk, rather than broken into a bunch of tiny bits that you have to hunt down. The joke is that in trying to be “extra neat and tidy,” we made things harder to follow – like a simple puzzle split into way too many pieces.

Level 2: Function Fragmentation

Let’s break down what’s happening in this meme. It references “Clean Code,” a famous book by Robert C. Martin that many developers treat like a bible for writing good, maintainable code. One of the book’s big guidelines is that each function should “do one thing” and be as small as possible. In theory, this makes code easier to maintain and reuse. The idea is that if every function is super focused (often called the Single Responsibility Principle in broader software design), you can understand and test that function quickly. This process of breaking a big function into many smaller ones is a form of refactoring – that’s when you reorganize code without changing what it does, usually to improve CodeQuality or readability.

But here’s the catch (and the joke): it’s possible to over-refactor and end up with what we might call “function fragmentation.” Instead of one clear 20-line function that you can read top-to-bottom and say, “Ah, I see exactly what’s happening,” you might get 25 teeny-tiny functions spread out over several files. Each tiny function does indeed do one very small thing, but now to understand the whole operation you have to hop around constantly. This can actually increase the CodeComplexity in a different way – not the complexity inside any single function, but the complexity of following the program’s flow. Cognitive load is a term for how much your brain has to keep track of at once. A single 20-line block might have higher local complexity, but at least you see all the logic in one place. Twenty-five micro-functions might each be simple, but making sense of the overall logic becomes a scavenger hunt, which raises the overall cognitive load.

To put it plainly: the meme is poking fun at how we sometimes take a good idea (write cleaner, smaller functions) and push it too far. This often happens to enthusiastic developers (especially earlier in their careers) after reading influential books or blog posts – they follow the advice to the letter in every situation, even when it doesn’t quite fit. OverEngineering is a tag that fits here: that’s when you design a solution that is more complicated than necessary just to be “clever” or follow a rule. The code ends up with lots of moving parts (in this case, many tiny functions) for something that wasn’t actually that complex to begin with.

Let’s use a simple coding example to illustrate the contrast:

# A straightforward approach (one clear function):
def process_order(order):
    # 1. Calculate total price with tax and discount
    tax = calculate_tax(order)
    discount = get_discount(order.customer)
    total = order.amount + tax - discount
    if total < 0:
        total = 0  # avoid negative totals
    # 2. Save the order and total to the database
    database.save(order.id, total)
    # 3. Log the result for auditing
    logger.info(f"Processed order {order.id} with total {total}")

In the single process_order function above (let's say it’s ~20 lines including comments), you can look at it and immediately understand the steps: compute the total, save it, log it. It’s all right there.

Now, imagine someone refactors this code after reading Clean Code. They might do this:

# An over-decomposed approach (many small functions):
def process_order(order):
    total = compute_total(order)
    save_order_total(order.id, total)
    log_order_processed(order.id, total)

def compute_total(order):
    tax = calculate_tax(order)
    discount = get_discount(order.customer)
    total = order.amount + tax - discount
    return max(total, 0)  # ensure non-negative

def save_order_total(order_id, total):
    database.save(order_id, total)

def log_order_processed(order_id, total):
    logger.info(f"Processed order {order_id} with total {total}")

# ...imagine other tiny helper functions, possibly each in separate files...

Now each helper function (compute_total, save_order_total, log_order_processed) is short and “does one thing.” That looks nice in isolation. But to grasp the full story of what happens when you call process_order, you have to open and read three other function definitions (and I hinted there could be even more tiny functions hidden elsewhere). It’s like reading a book but having to chase down footnotes on different pages for every other sentence. DeveloperExperience_DX suffers because the reader (developer) must keep jumping around. The code might formally follow the Clean Code guideline, but ironically it can become harder to read and maintain. In a code review or debugging session, a newcomer might sigh and say, “Why not just put this logic in one place? I keep losing track.”

To connect with the meme’s phrasing: the tweet says “one 20-line function that you could look at and say 'I know exactly what this function is doing'.” That’s the ideal of clarity. The alternative is those 25 small functions where you don’t immediately see what the overall outcome is, because it’s fragmented. The humor here is a bit self-deprecating for developers: we earnestly tried to follow best practices (like good little engineers), and sometimes we ended up making the codebase feel like a jigsaw puzzle. It’s a lesson in balancing principles with pragmatism. Refactoring and writing clean code are still good practices, but you have to know when to stop slicing and dicing. The goal is readable code, not just arbitrarily short functions. In short, make things as simple as possible, but no simpler – otherwise you might refactor your way into confusion, just as this meme describes.

Level 3: Microfunction Overdose

It turns out you can make code too clean for its own good. This meme nails a classic CodeQuality trap: after devouring Clean Code by Robert C. Martin (aka Uncle Bob), many of us went on a function decomposition frenzy. The book preached “small functions that do one thing,” which sounds great – until someone takes it to the extreme and we end up with 25 bite-sized functions scattered across 5 files to accomplish what one clear 20-line function did before. This tweet is the battle-scarred voice of experience saying, remember when we all drank the Clean Code Kool-Aid and created a monster? 😅

In practice, splitting every little step into its own microFunction() can hurt more than help. Sure, each tiny function is easy to read in isolation (they’re like 5 lines of obvious code each). But the humor (and pain) here is that to follow the program’s logic, you now have to jump in and out of dozens of functions and files. What used to be a straightforward story becomes a choose-your-own-adventure labyrinth. OverEngineering at its finest! There’s an industry term for this kind of overzealous abstraction: a code smell, meaning a hint that something’s off in the code’s design. Ironically, a technique meant to improve CodeQuality has itself become a CodeSmells exhibit.

Seasoned developers know the trade-off all too well. We strive for that sweet spot where functions are just the right size – not ginormous god-methods, but also not molecular-sized jumping beans. This meme exaggerates a very real tendency, especially among intermediate devs who read Bob Martin’s gospel and apply it without context. The result? DeveloperFrustration for anyone trying to maintain that code. The intent was noble (make each function simple), but the outcome is a cognitive spaghetti 🍝 of function calls. When you’re on-call at 3 AM debugging a production issue, nothing induces panic like grepping for which of the twenty-five doOneTinyThing() functions actually holds the bug. As a cynical veteran might say: "clean code" that isn’t readable isn’t really clean at all.

Why is this so relatable? Because it’s a rite of passage in our field. We’ve seen methods that were easy to understand before, now broken into a dozen microfunctions that each technically do one thing, but collectively they obscure the intent. It’s a RefactoringNeeded scenario in hindsight – the code was refactored too much! The tweet’s tone (“Remember back when...”) winks at a shared memory: the early 2010s craze of applying clean_code_book principles to every single line. Senior engineers now often debate this tension: purist code-quality dogma vs. practical readability. We chuckle (and cringe) because we all either made this mistake ourselves or had to untangle someone else’s over-engineered “clean” code. It’s a case of DeveloperExperience_DX gone wrong – the developer experience of reading the code actually got worse. The real punchline: sometimes that original 20-line function was the cleanest solution after all, and it took a journey through messy “clean” abstractions to appreciate it.

Description

A screenshot of a tweet from Ryan Winchester (@ryanrwinchester) on a black background. The tweet reads: 'Remember back when we all read Clean Code and then to do one thing we wrote 25 small functions across several files instead of one 20-line function that you could look at and say "I know exactly what this function is doing"'. This post humorously critiques the dogmatic application of principles from the popular software development book 'Clean Code' by Robert C. Martin. The joke resonates with experienced developers who have witnessed or participated in over-engineering where the effort to create 'clean' code, by breaking down functions into minuscule, single-purpose units, ironically results in a codebase that is harder to follow due to excessive fragmentation and indirection, compared to a slightly longer but self-contained and immediately understandable function

Comments

7
Anonymous ★ Top Pick Applying 'Clean Code' too literally is how you end up with a call stack deep enough to be a microservices architecture
  1. Anonymous ★ Top Pick

    Applying 'Clean Code' too literally is how you end up with a call stack deep enough to be a microservices architecture

  2. Anonymous

    PagerDuty went off, I hit “Go to Definition,” and five minutes later I’d depth-first-searched 27 one-line helper methods across six packages - turns out the real bug was still in the catch block of the original 20-line function we refactored for “readability.”

  3. Anonymous

    The junior who refactored your 20-line function into 25 files just got promoted to architect for "demonstrating deep understanding of SOLID principles" while you're still debugging their AbstractFactoryFactoryBuilder

  4. Anonymous

    Ah yes, the classic Clean Code journey: from writing God objects to creating a distributed microservices architecture just to calculate a sum. We've all been there - religiously applying SOLID principles until our 20-line function becomes an archaeological dig across 8 files, 3 interfaces, 2 abstract classes, and a factory pattern. The real clean code was the cognitive overhead we accumulated along the way. Turns out, sometimes a straightforward function that does exactly what it says on the tin beats a beautifully abstracted maze that requires a PhD in your own codebase to understand

  5. Anonymous

    Clean Code's SRP: Transforming a glanceable 20-liner into a 25-file call graph that demands a debugger just to grok

  6. Anonymous

    After “Clean Code” we turned a clear 20‑liner into 25 SRP helpers; complexity didn’t vanish - it just relocated to indirection and a stack trace that needs pagination

  7. Anonymous

    Clean Code said one function per idea; now my Go to Definition key has the worst P99 in the org - compilers inline, humans just thrash their L1 instruction cache

Use J and K for navigation