Draft / Scheduled Content
This article is a draft or scheduled for future publication. The content is subject to change.
Why We Should Stop Writing 'Smart' Code
The Ego of the One-Liner
We have all seen the pull request:
A developer has solved a complex business problem by writing a single, dense line of code. It uses nested ternary operators, array reduction, bitwise operations, and a dynamic Regex evaluation.
The developer is proud. They feel like a genius. They have compressed 30 lines of standard logic into a single, elegant sentence.
Other developers review the PR, stare at the line for five minutes, pretend to understand what it does, and reply: “Nice! Clever one-liner.”
This is a cultural failure.
In software engineering, “clever” is a dirty word. Writing “smart” code is a sign of ego, not skill. It is a maintenance liability that increases cognitive load, introduces subtle edge-case bugs, and slows down your team.
We need to stop writing smart code. We need to start writing boring code.
The Reading vs. Writing Asymmetry
The fundamental error of the clever programmer is optimizing for writing speed instead of reading speed.
You write a line of code once. But that line will be read, analyzed, and debugged dozens of times by other developers—and by your future self at 3:00 AM when production is down.
When you write clever code, you are shifting the cognitive workload from yourself to the readers.
Consider this JavaScript example that filters and maps an array of transactions:
// Clever, concise "smart" code
const process = t => t.filter(x => x.amt > 100 && x.status === 'ok').map(({ id, amt: a }) => ({ id, val: a * 1.2 }));
This code works. It’s short. But it requires the reader to decode the variable abbreviations (t, x, a), mentally parse the inline destructurings, and calculate the mapping in their head.
Now look at the boring version of the exact same logic:
// Boring, explicit, readable code
function getLargeApprovedTransactions(transactions) {
const largeApprovedTransactions = transactions.filter(transaction => {
const isLargeAmount = transaction.amount > 100;
const isApproved = transaction.status === 'ok';
return isLargeAmount && isApproved;
});
return largeApprovedTransactions.map(transaction => {
const taxedValue = transaction.amount * 1.2;
return {
id: transaction.id,
value: taxedValue
};
});
}
Yes, the boring version is 15 lines instead of 1. Yes, it took 30 seconds longer to type.
But a junior developer can read the boring version and understand exactly what it does in 2 seconds. They don’t have to guess what x is, what 1.2 represents, or what the filter condition means. The code is self-documenting.
The Debugging tax
Clever code is a nightmare to debug.
If your one-liner throws a TypeError: Cannot read properties of undefined at runtime, the stack trace points to the line number.
But because your entire operation is on a single line, the stack trace cannot tell you which part of the expression failed. Was it x.amt? Was it the destructuring? Was it the mapping?
You have to break the line apart, insert print statements, or run a step-by-step debugger just to locate the failure.
Furthermore, clever code makes code review incredibly difficult. It is easy to hide bugs in dense, complex expressions. A reviewer scanning a PR will easily miss a logical error or an off-by-one boundary condition in a nested ternary sequence, whereas the same bug in an explicit if/else block stands out immediately.
+-------------------------------------------------------------+
| The Clever Code Cycle |
| |
| 1. Write a complex one-liner in 2 minutes. |
| 2. Feel like a programming wizard. |
| 3. 6 months later, production crashes on that line. |
| 4. Spend 2 hours decoding your own wizardry to fix it. |
| |
| Result: Net negative productivity. |
+-------------------------------------------------------------+
The “Smart” Patterns to Avoid
Here are the most common clever patterns we should ban from our codebases:
1. Nested Ternaries
A single ternary operator (condition ? a : b) is fine. A nested ternary (conditionA ? (conditionB ? c : d) : e) is a crime. Use if/else blocks or early returns.
2. Magic Numbers and Regex Wizardry
If your code contains raw regular expressions or magic numbers without context, you are writing smart code. Extract them to named variables or functions:
// Bad
if (email.match(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/)) {}
// Good
const isValidEmailFormat = email.match(EMAIL_REGEX);
if (isValidEmailFormat) {}
3. Dynamic Meta-Programming
Using Reflection, dynamic key evaluation, or framework-level black magic to save 10 lines of explicit mapping is almost never worth it. It breaks IDE autocomplete, makes global search-and-replace impossible, and confuses anyone who doesn’t know the meta-framework internals.
The Mark of a Senior Engineer
Junior developers write complex code because they want to prove they can. They think that writing code that is hard to understand is a sign of intelligence.
Senior developers write simple code because they know they will have to maintain it. They understand that their value is not in their ability to write complex code, but in their ability to make complex problems simple.
As Tony Hoare famously said:
“There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies.”
Write code that is so simple that it is obviously correct. Make your code boring.
Related Content
Your Unit Tests Are Mocking You
Unit testing with mocked dependencies has become a software industry obsession. We write tests that verify our code behaves against mock assumptions, resulting in green test suites that pass while production crashes. It is time to embrace integration tests with real, lightweight dependencies.
The Fallacy of DRY: Why You Should Write Duplicated Code First
Don't Repeat Yourself (DRY) is one of the first design principles programmers learn. But applying it too early creates tightly coupled, hyper-flexible abstractions that crumble under the weight of changing requirements. Write duplicated code until the structure reveals itself.
The CSS-in-JS Fever Dream is Over
For years, frontend developers insisted that CSS should be written in JavaScript. We got dynamic styling at the cost of massive runtime overhead, bloated bundle sizes, and broken browser style injection. Now, the fever dream is over. Tailwind and modern CSS features have won.