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.
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.
🔧 Some exercises may still have errors. If something seems wrong, use the Feedback button (bottom-right of the page) to report it — it helps us fix it fast.
Hint: If you have to explain a line with a comment, rename it instead. Introduce an explanatory variable — the name IS the documentation.
✗ Your version