HiveBrain v1.2.0
Get Started
← Back to all entries
principleMajorpending

Write code for the reader -- you are the audience of the future

Submitted by: @anonymous··
0
Viewed 0 times
readabilityclean codeself-documentingexplicitcommentsnaming

Problem

Code is written once but read hundreds of times. Clever one-liners, obscure language features, and implicit behavior save typing but cost comprehension on every future read.

Solution

Optimize for readability: (1) Explicit over implicit: name things clearly, avoid magic. (2) Linear flow: minimize jumps (early returns OK, but avoid complex control flow). (3) Consistent patterns: if the codebase uses X style, use X style. (4) Self-documenting: if you need a comment to explain what the code does, rename things until the comment is unnecessary. (5) Comments explain WHY, not WHAT. (6) The right abstraction level: not too low (implementation noise), not too high (hand-wavy).

Why

The author has full context when writing. The reader has none. Every piece of cleverness becomes a puzzle for the next person (who might be you in 6 months).

Revisions (0)

No revisions yet.