The Moment It Clicked
“Damn it Doug! array_map is not a design pattern!”
I will never forget hearing that yelled across the office during a code review.
And to this day, every time I run across code that’s trying a little too hard to be clever, that line pops back into my head.
How We Get There
Doug was a smart engineer. Seriously smart.
But he had a habit I’ve seen in a lot of really sharp developers — myself included, if I’m being honest. He’d find a tool, a pattern, or a concept he liked…
…and then use it everywhere.
At some point, that turned into what we started calling — half joking, half traumatized —
The array_map design pattern
Which, to be clear, is not a thing.
The Problem in Practice
I remember reviewing a piece of code from his team where it was literally:
- an
array_map - inside an
array_map - calling another
array_map - returning an
array_map
And I’m not exaggerating.
It worked and was technically correct. It was also an absolute nightmare to read, debug, and maintain.
Clever vs Clear
And that’s the part that matters. Because this isn’t really about array_map. It’s about what happens when we start optimizing for cleverness instead of clarity.
I’ve been guilty of this too -- writing code that made me feel smart, code that looked elegant. Expressive. Maybe even impressive in a code review.
And then six months later, someone else is digging through it trying to fix a bug, wondering what in the world I was thinking.
Sometimes that “someone else” was me.
The Real Issue
The problem isn’t the tool or the technique. It’s how and when we choose to apply it.
The problem is forgetting that code has a second life:
being read, understood, and maintained by someone else.
Most systems don’t fail because they weren’t clever enough. They fail because no one can understand them anymore.
Complexity vs Control
Now, to be fair — I’m not a fan of nested loops either.
If I can avoid them, I will.
I’ll happily spend extra time structuring data, reshaping inputs, or breaking problems apart so I don’t have to stack loops on loops.
That’s not about performance as much as it is about clarity and control. But there’s a difference between avoiding complexity…
…and hiding it behind layers of abstraction that make things harder to follow.
What Good Looks Like
Sometimes the right solution isn’t the most clever one. It’s the one that makes the intent obvious.
Something like:
foreach ($items as $item) {
$result[] = transform($item);
}
It’s not fancy, nor is is going to win you any style points. But anyone who reads it knows exactly what it’s doing.
And more importantly — they can change it without fear.
That’s the real goal. Not just writing code that works. Writing code that survives.
Closing Thought
Just because a tool exists doesn’t mean it should drive the design. Just because something is expressive doesn’t mean it’s appropriate. And just because it feels clever…
doesn’t mean it’s a good idea.
“array_map is not a design pattern.”
It’s a tool.
Use it when it makes things clearer. Put it down when it doesn’t.
Cross-posted: LinkedIn | Medium
Top comments (0)