Milan Jovanović
Read post

DRY Is the Most Misunderstood Rule in Programming

This title could be clearer and more informative.Try out Clickbait Shieldfor free (5 uses left this month).

DRY (Don't Repeat Yourself) is widely misunderstood as a rule about eliminating identical-looking code, but its original definition from The Pragmatic Programmer is about knowledge, not syntax. Two pieces of code can look the same yet represent entirely different domain concepts — merging them creates wrong abstractions that are harder to undo than the duplication they replaced. The author illustrates this with address validation and shared Order types across module boundaries, showing how premature deduplication introduces hidden coupling. The recommended approach: wait for the third occurrence, then ask whether both copies encode the same fact and must change together. If yes, extract. If not, leave them separate. Good abstractions are discovered from concrete cases, not guessed upfront.

    #general-programming#domain-driven-design
Jun 05•6m read time•From milanjovanovic.tech
Post cover image
Table of contents
What DRY Actually SaysThe Mistake: Deduplicating Code, Not KnowledgeThe Wrong Abstraction Costs More Than DuplicationWhere It Hurts Most: Across BoundariesThe Rule I Use: Wait for the Third TimeWhen DRY Is RightSummary
7.3K Impressions
Milan Jovanović's image
Milan Jovanović

MilanJovanovic's platform covers topics related to software development, technology trends, and cod...

722 Followers

•

2.9K Upvotes

Would you recommend this post?

Copy link
WhatsApp
Facebook
X
New Squad
  • © 2026 Daily Dev Ltd.
  • Guidelines
  • Explore
  • Tags
  • Sources
  • Squads
  • Leaderboard