Code is hard to read when you use tricky names with no semantics or rely on accidental language complexity.

TL;DR: Don't try to look too smart. Clean code emphasizes readability and simplicity.

Problems πŸ˜”

Solutions πŸ˜ƒ

Refactorings βš™οΈ

https://hackernoon.com/refactoring-005-replace-comment-with-function-name?embedable=true

Examples

Context πŸ’¬

You might feel the urge to show off your skills with complex tricks or cryptic names.

This makes your code harder to read, debug, and extend.

You must remember that you write code for humans, not machines.

Sample Code πŸ“–

Wrong 🚫

function primeFactors(n) {
  var f = [],  i = 0, d = 2;  
  
  for (i = 0; n >= 2; ) {
     if(n % d == 0) {
       f[i++]=(d); 
       n /= d;
    }
    else {
      d++;
    }     
  }
  return f;
}

Right πŸ‘‰

function primeFactors(numberToFactor) {
  var factors = [], 
      divisor = 2,
      remainder = numberToFactor;
  
  while(remainder>=2) {
    if(remainder % divisor === 0) {
       factors.push(divisor); 
       remainder = remainder / divisor;
    }
    else {
      divisor++;
    }     
  }
  return factors;
}

Detection πŸ”

Automatic detection is possible in some languages.

Look for warnings about complexity, bad names, post-increment variables, and similar patterns.

Exceptions πŸ›‘

Tags 🏷️

Level πŸ”‹

Why the Bijection Is Important πŸ—ΊοΈ

When you keep a clear bijection between your program and the MAPPER.

Other developers and your future self can understand it quickly.

Clever tricks break this mapping and force future readers to guess instead of reading.

AI Generation πŸ€–

AI models sometimes generate clever one-liners or compressed solutions.

They might look smart but lack readability and semantics.

AI Detection 🧲

AI assistants can rewrite clever code into readable code if you instruct them to prefer clarity to optimization.

Try Them! πŸ› 

Remember: AI Assistants make lots of mistakes

Suggested Prompt: correct=Remove cleverness from code

Without Proper Instructions

With Specific Instructions

ChatGPT

ChatGPT

Claude

Claude

Perplexity

Perplexity

Copilot

Copilot

You

You

Gemini

Gemini

DeepSeek

DeepSeek

Meta AI

Meta AI

Grok

Grok

Qwen

Qwen

Conclusion 🏁

Clever developers write cryptic code to brag.

Smart developers write clean code.

Clear beats clever.

Relations πŸ‘©β€β€οΈβ€πŸ’‹β€πŸ‘¨

https://hackernoon.com/code-smell-02-dont-let-mysterious-numbers-rule-your-code

https://hackernoon.com/how-to-find-the-stinky-parts-of-your-code-part-iv-7sc3w8n

https://hackernoon.com/how-to-find-the-stinky-parts-of-your-code-part-ix-7rr33ol

https://hackernoon.com/how-to-find-the-stinky-parts-of-your-code-part-ix-7rr33ol

https://hackernoon.com/how-to-find-the-stinky-parts-of-your-code-part-xvi

https://hackernoon.com/how-to-find-the-stinky-parts-of-your-code-part-xi-sit35t1

https://hackernoon.com/how-to-find-the-stinky-parts-of-your-code-part-vii-8dk31x0

https://hackernoon.com/how-to-find-the-stinky-parts-of-your-code-part-x-i7r34uj

https://hackernoon.com/how-to-find-the-stinky-parts-of-your-code-part-xxxx

https://hackernoon.com/how-to-find-the-stinky-parts-of-your-code-part-v-evj3zs9

https://hackernoon.com/how-to-find-the-stinky-parts-of-your-code-part-xix

https://hackernoon.com/how-to-find-the-stinky-parts-of-your-code-part-xxix

https://hackernoon.com/how-to-find-the-stinky-parts-of-your-code-part-xliii

https://hackernoon.com/how-to-find-the-stinky-parts-of-your-code-part-xxxvi

https://hackernoon.com/how-to-find-the-stinky-parts-of-your-code-part-xxvi

https://hackernoon.com/how-to-find-the-stinky-parts-of-your-code-part-vii-8dk31x0

https://hackernoon.com/how-to-find-the-stinky-parts-of-your-code-part-v-evj3zs9

https://hackernoon.com/how-to-find-the-stinky-parts-of-your-code-part-v-evj3zs9

https://hackernoon.com/how-to-find-the-stinky-parts-of-your-code-part-xiv

More Information πŸ“•

https://ardalis.com/are-boolean-flags-on-methods-a-code-smell/?embedable=true

Also Known as

Credits πŸ™

Photo by NeONBRAND on Unsplash


Programming can be fun, so can cryptography; however they should not be combined.

Kreitzberg & Shneiderman

https://hackernoon.com/400-thought-provoking-software-engineering-quotes


This article is part of the CodeSmell Series.

https://hackernoon.com/how-to-find-the-stinky-parts-of-your-code-part-i-xqz3evd?embedable=true