Menu

Post image 1
Post image 2
1 / 2
0

When Duplicate Code Is the Better Design

DEV Community·Adam - The Developer·about 14 hours ago
#l8QrVSd2
#dev#fullscreen#function#user#every#article
Reading 0:00
15s threshold

You've seen the developer. Maybe you are the developer. They discover DRY — ✨ Don't Repeat Yourself ✨ — and something switches in their brain. A primal need awakens. Every duplicated string, every similar-looking function, every pair of lines that rhyme in the wrong light becomes a personal affront . An itch. A moral failing. Two weeks later, their codebase looks like a game of Jenga where every piece is also load-bearing, also abstract, also parametrized six ways to Sunday, and also, crucially, completely impossible to understand . Congratulations. You've achieved ✨ DRY ✨. You've also achieved a codebase that will ruin your next three Fridays and everyone's. What DRY Actually Says (and Doesn't) DRY comes from The Pragmatic Programmer by Andy Hunt and Dave Thomas. The actual rule is: "Every piece of knowledge must have a single, unambiguous, authoritative representation within a system." Notice what it says: knowledge . it's not code . it's not characters .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More