Code is read far more often than it is written. The best programs are not the shortest or the most clever — they are the ones the next person can understand in one pass.
Name things after their meaning
A variable name is a contract. Compare these:
// unclearconst d = items.reduce((a, c) => a + c.price, 0);
// clearconst totalPrice = items.reduce( (sum, item) => sum + item.price, 0,);The second version takes no explanation. It reads like the sentence it describes.
Prefer small, obvious functions
In Python, a tiny helper can remove a whole class of reasoning:
def is_weekend(day: int) -> bool: return day in (5, 6)
def is_busy(slots: list[tuple[int, int]]) -> bool: return any(start <= 17 < end for start, end in slots)Each function answers one question. There is no need to reverse-engineer a compound expression.
Make ownership explicit in C++
In C++, express intent through types and names rather than comments that drift out of date:
#include <memory>#include <string>
struct Task { std::string name; std::chrono::milliseconds estimate;};
// The caller keeps ownership; we only read.void print_summary(const Task& task) { std::cout << task.name << " (~" << task.estimate.count() << "ms)\n";}Using const Task& tells the reader this function will not mutate or retain the object. The signature is the documentation.
Cleverness has a cost
Every clever trick trades a little future readability for a little present brevity. Reserve that budget for places where it genuinely pays — hot paths with a measured bottleneck. Everywhere else, choose the boring, obvious version.
Write for the next person who will read the code — that person is often you, six months from now.