← Back to list

🌀 Buzzword Breakdown #14 — “DRY (Don’t Repeat Yourself)”

“This code isn’t DRY — clean it up.” But wait… is DRY just about avoiding copy-paste?

Thiraphat Phutson · 2025-04-17 17:26 · 2 claps · 1.6 min read
#dont-repeat-yourself #dry #buzzwords
Open on Medium ↗

🌀 Buzzword Breakdown #14 — “DRY (Don’t Repeat Yourself)”

“This code isn’t DRY — clean it up.” But wait… is DRY just about avoiding copy-paste?

🔹 What does DRY mean?

DRY stands for Don’t Repeat Yourself — a principle that says: “Every piece of knowledge or logic should have a single, unambiguous representation.”

The goal:

Reduce duplication → so changes happen in one place only Improve clarity → so everyone knows where the logic lives

📦 Common ways devs use this buzzword:

  • “Too much duplication — make it DRY.”
  • “Extract a helper function so we don’t repeat this.”
  • “You changed one place but forgot the other.”

A lot of people think DRY = “No copy-paste.” But true DRY is about removing logic duplication and duplicated knowledge — not just lines.

🔍 A simple violation of DRY

if (status === 'success') {
  toast.success('Done!');
}
...
if (status === 'success') {
  toast.success('Done!');
}

Repeating the same logic = high maintenance cost Any change = fix in multiple places

✅ DRY version

function showSuccess() {
  toast.success('Done!');
}

if (status === 'success') {
  showSuccess();
}

Now we only change in one place = safer, easier to maintain

🧠 DRY goes beyond code

  • 💾 DRY configs → Avoid repeating environment values in multiple files
  • 📄 DRY documentation → Don’t duplicate descriptions across multiple wikis
  • 🔁 DRY tests → Use shared test helpers, fixtures, or mocks

🚫 Common DRY mistakes

  • Over-DRYing → Extracting abstractions that are hard to understand → DRY is not worth it if it kills readability
  • DRYing similar-but-different logic → False abstraction = future bugs
  • Forgetting that some repetition is okay if it improves clarity and local context

✅ Smart ways to stay DRY

  • Only DRY when the logic is truly identical
  • Don’t DRY too early — wait until duplication becomes painful
  • DRY with readability in mind — code should still tell a clear story
  • Talk with your team: “Is this worth extracting?”

📌 Summary

DRY isn’t just about avoiding copy-paste. It’s about intentional reuse of logic and knowledge — done clearly.

Good DRY = less effort, fewer bugs, easier changes. Bad DRY = mystery abstractions and tech debt in disguise.

🏷️ #buzzwordbreakdown #dry #cleancode #softwareengineering #refactor #frontend #javascript


메타데이터
post_id
4ef0559d6cfa
slug
buzzword-breakdown-14-dry-dont-repeat-yourself-4ef0559d6cfa
url
https://medium.com/@thiraphat-ps-dev/buzzword-breakdown-14-dry-dont-repeat-yourself-4ef0559d6cfa
canonical_url
https://medium.com/@thiraphat-ps-dev/buzzword-breakdown-14-dry-dont-repeat-yourself-4ef0559d6cfa
author_url
https://medium.com/@thiraphat-ps-dev
status
ok
fetched_at
2026-08-09 17:14:00