Skip to main content
Clean Code 50 XP · 5 min

G16: The Obscured Intent

Code that tries to be clever is code that fails to communicate — density and brevity at the cost of clarity are not virtues.

Showing
Ad (728×90)

Symptoms of Obscured Intent

G16: Code fails to communicate when the implementation hides the author's intent. Symptoms: magic numbers with no name; single-letter variables in non-trivial contexts; overly compact boolean chains; bitwise tricks where arithmetic would be clearer (n & 1 instead of n % 2 === 1); one-liners that do three things. Each symptom trades the reader's comprehension for the writer's cleverness.

The Fix: Expose the Why

Every optimization toward brevity that hides meaning is a net negative. The fix: use named constants instead of magic numbers. Introduce explanatory variables that capture the result of a sub-expression. Expand one-liners into multi-step sequences where each step has a meaningful name. The rule of thumb: if you have to add a comment to explain a line, rename or decompose it instead.

Code Challenge

Expose the intent by naming the concepts buried in the clever expressions.

Key takeaway

G16: Clever code impresses only its author. Clear code serves its readers — and code is read far more often than it is written. Brevity at the cost of clarity is not a virtue.

Done with this lesson?

Mark it complete to earn XP and track your progress.