Skip to content
Engineering

Why I Stopped Writing Clever Code

Clever code feels great to write and terrible to maintain. Here's what changed my mind, and the three questions I ask before landing anything tricky.

Md Mahedi Zaman Zaber2 min read

For a long time, I measured my own growth as an engineer by how compact I could make things. A one-liner that replaced ten lines felt like a small victory. A clever use of a language feature nobody on the team had seen before felt like a flex worth committing.

Then I had to debug that code six months later.

The tell was always the same

Every time I opened an old file and felt a flicker of “wait, what does this do,” the answer traced back to the same instinct: I had optimized for the moment of writing, not the years of reading that would follow.

Code is read far more often than it’s written. That’s not a new observation — it’s practically a cliché at this point — but knowing it and feeling it are different things. I didn’t really feel it until I was the one squinting at my own past cleverness, trying to reconstruct intent from a chain of ternaries.

The best code I’ve written recently is code I’m slightly embarrassed to show off. It’s boring. It reads like a sentence.

Three questions before landing anything tricky

Now, before I let a clever solution into a codebase — mine or anyone else’s — I ask:

  1. Would a teammate understand this in thirty seconds, without me in the room?
  2. Does the cleverness buy something real — measurable performance, meaningfully less code — or just satisfy my own taste?
  3. If this breaks at 2am, how long would it take a stranger to find the bug?

If the answer to any of these is uncomfortable, I rewrite it plainly. Almost always, the plain version is not meaningfully longer. It’s just less impressive, which turns out to be exactly the point.

A small example

Here’s the kind of thing I used to write:

const result = items.reduce((a, c) => (c.active ? [...a, c.id] : a), [] as string[]);

And here’s what replaced it:

const result: string[] = [];
for (const item of items) {
if (item.active) result.push(item.id);
}

The second version is not shorter. It is, however, something I can read at 2am without re-deriving what reduce is doing in this particular case. That trade — a few extra characters for zero re-derivation cost — is one I’ll make every time now.

What I’d tell an earlier version of me

Cleverness is a tool, not a virtue. Save it for the handful of places where it earns its keep — a genuinely hot path, a genuinely elegant abstraction that removes real duplication — and write everything else like you’re explaining it to someone who’s tired. Future you will be tired. Be kind to them.

ShareXLinkedInReddit

Comments