The junior developer celebrates the code they write. The senior developer celebrates the code they delete.

There is a strange satisfaction in watching lines disappear. Each deletion is a small act of liberation — freeing the codebase from weight it no longer needs to carry. Like pruning a tree, we remove the dead branches so the living ones can reach further toward the light.

The Weight of Every Line

Every line of code is a liability. It must be read, understood, maintained, tested, and eventually debugged. It consumes cognitive space in the minds of everyone who encounters it. It demands attention every time someone opens the file.

function getUserData($userId)
{
    // TODO: Refactor this later
    // Old implementation (keeping just in case)
    // $user = DB::query("SELECT * FROM users WHERE id = $userId");
    
    // New implementation
    $user = User::find($userId);
    
    // Might need this later
    // $user->loadLegacyData();
    
    return $user;
}

This function carries ghosts. Commented code that “might be needed later” but never is. TODO notes that become permanent residents. Each ghost whispers doubt into the minds of future readers: Was this important? Should I uncomment this? What did they know that I don’t?

Delete the ghosts.

Version Control Remembers

We cling to old code like memories we’re afraid to lose. But version control never forgets. Git holds everything you’ve ever written in its infinite memory. That clever solution you’re afraid to delete? It’s one git log away.

git log --all --full-history -- path/to/deleted/file.php

The past is always recoverable. The present should be clean.

The Courage to Subtract

Addition requires knowledge. Subtraction requires wisdom.

Anyone can add features, add dependencies, add abstractions. It takes experience to recognize when less is more. When that helper class adds more confusion than clarity. When that abstraction layer is just indirection wearing a fancy name.

The best refactoring sessions end with fewer files than they started with.

Signs You Should Delete

  • You scroll past it without reading
  • You copy-paste from Stack Overflow to fix it instead of understanding it
  • The tests mock it so heavily that the mock is larger than the code
  • No one remembers why it exists, but everyone is afraid to touch it
  • It handles an edge case that hasn’t occurred in three years

The Minimalist Function

function isValid($value)
{
    return !empty($value);
}

One line. One purpose. No comments needed because the name explains everything. No parameters to configure because the behavior is obvious. No edge cases because there are no edges.

This is code that earns its existence.

Death and Renewal

In nature, death enables life. Fallen leaves become soil for new growth. Dead code should decompose too — returning its cognitive space to the living parts of the system.

A codebase that never deletes only accumulates. It becomes a museum of past decisions, each exhibit requiring preservation but serving no visitor. Eventually, developers stop reading and start guessing. The code becomes folklore instead of documentation.

The Practice

Before committing new code, ask: What can I delete to make room for this?

Before closing a pull request, ask: Does every line I’m adding justify its permanent residence?

Before ending the day, ask: Is this codebase lighter than when I found it?


The master programmer writes code that makes itself unnecessary. Then deletes it.